mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Changing/updating name of matlab scripts
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@221 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -1,340 +0,0 @@
|
||||
|
||||
%---------------------------------------------------------
|
||||
% MatLab script.
|
||||
% This shows some informations logged by the application.
|
||||
% This script may work directly with octave.
|
||||
%---------------------------------------------------------
|
||||
% Just put along LogF.txt and LogI.txt files generated
|
||||
% (look in the application working directory).
|
||||
% The files must have the same number of lines.
|
||||
%
|
||||
% Dependency : importfile.m
|
||||
%---------------------------------------------------------
|
||||
|
||||
%--------------------
|
||||
% Parameters
|
||||
%--------------------
|
||||
|
||||
close all
|
||||
clear all
|
||||
|
||||
Prefix = '.';
|
||||
%Prefix = './Results';
|
||||
|
||||
DataSet = '';
|
||||
%DataSet = 'NewCollege';
|
||||
%DataSet = 'CityCentre';
|
||||
%DataSet = 'Lip6Indoor';
|
||||
%DataSet = 'Lip6Outdoor';
|
||||
%DataSet = 'Lip6Outdoor_1Hz';
|
||||
%DataSet = 'UdeS_1Hz';
|
||||
|
||||
% The Ground Truth is a squared bmp file (size must match the log files
|
||||
% length) where white dots mean loop closures.
|
||||
% Grey dots mean 'loop closures to ignore', this happens when the rehearsal
|
||||
% doesn't match consecutive images together.
|
||||
PrefixGT = '.';
|
||||
%PrefixGT = './GT';
|
||||
GroundTruthFile = [PrefixGT '/' '090206-3_GT.bmp'];
|
||||
%GroundTruthFile = [PrefixGT '/' DataSet '.bmp'];
|
||||
|
||||
|
||||
%---------------------------------------------------------
|
||||
|
||||
display(' ');
|
||||
display('Loading log files...');
|
||||
importfile([Prefix '/' DataSet '/' 'LogF.txt']);
|
||||
% COLUMN HEADERS :
|
||||
% 1 totalTime
|
||||
% 2 timeMemoryUpdate,
|
||||
% 3 timeReactivations,
|
||||
% 4 timeLikelihoodCalculation,
|
||||
% 5 timePosteriorCalculation,
|
||||
% 6 timeHypothesesCreation,
|
||||
% 7 timeHypothesesValidation,
|
||||
% 8 timeRealTimeLimitReachedProcess,
|
||||
% 9 timeStatsCreation
|
||||
% 10 highestHypothesisValue
|
||||
% 11 vpLikelihood
|
||||
% 12 maxLikelihood
|
||||
% 13 sumLikelihoods
|
||||
% 14 mean likelihood
|
||||
% 15 stddev likelihood
|
||||
|
||||
importfile([Prefix '/' DataSet '/' 'LogI.txt']);
|
||||
% COLUMN HEADERS :
|
||||
% 1 lcHypothesisId,
|
||||
% 2 mostLikelihoodId,
|
||||
% 3 signaturesRemoved,
|
||||
% 4 hessianThr,
|
||||
% 5 wordsNewSign,
|
||||
% 6 dictionarySize,
|
||||
% 7 this->getSTMem().size(),
|
||||
% 8 rejectLoopReason,
|
||||
% 9 processMemoryUsed,
|
||||
% 10 databaseMemoryUsed
|
||||
% 11 signaturesReactivated
|
||||
% 12 lcHypothesisReactivated
|
||||
% 13 refUniqueWordsCount
|
||||
% 14 reactivateId
|
||||
% 15 non nulls count
|
||||
|
||||
startAt = 1;
|
||||
% endAt = 1175;
|
||||
endAt = length(LogF(:,1));
|
||||
|
||||
figure
|
||||
H1 = plot(LogF(startAt:endAt,1)*1000);
|
||||
hold on
|
||||
% H2 = plot(1:length(LogF(startAt:endAt,1)), ones(length(LogF(startAt:endAt,1)),1).*mean(LogF(startAt:endAt,1))*1000, 'r-')
|
||||
%title('Total process time / Location')
|
||||
ylabel('Time (ms)')
|
||||
xlabel('Location indexes')
|
||||
meanTime = mean(LogF(startAt:endAt,1))*1000
|
||||
%plot([1 length(LogF(:,1))], [800 800], 'r')
|
||||
%plot([1 length(LogF(:,1))], [1000 1000], 'k')
|
||||
|
||||
|
||||
% -------------------------
|
||||
% Time details
|
||||
figure
|
||||
subplot(7,1,1)
|
||||
plot(LogF(startAt:endAt,2)*1000)
|
||||
title('timeMemoryUpdate (ms)')
|
||||
|
||||
subplot(7,1,2)
|
||||
plot(LogF(startAt:endAt,3)*1000)
|
||||
title('timeReactivations (ms)')
|
||||
|
||||
subplot(7,1,3)
|
||||
plot(LogF(startAt:endAt,4)*1000)
|
||||
title('timeLikelihoodCalculation (ms)')
|
||||
|
||||
subplot(7,1,4)
|
||||
plot(LogF(startAt:endAt,5)*1000)
|
||||
title('timePosteriorCalculation (ms)')
|
||||
|
||||
subplot(7,1,5)
|
||||
plot(LogF(startAt:endAt,6)*1000)
|
||||
title('timeHypothesesCreation (ms)')
|
||||
|
||||
subplot(7,1,6)
|
||||
plot(LogF(startAt:endAt,7)*1000)
|
||||
title('timeHypothesesValidation (ms)')
|
||||
|
||||
subplot(7,1,7)
|
||||
plot(LogF(startAt:endAt,8)*1000)
|
||||
title('timeStatsCreation (ms)')
|
||||
|
||||
% -------------------------
|
||||
figure
|
||||
plot([LogF(startAt:endAt,2) sum(LogF(startAt:endAt,2:3),2) sum(LogF(startAt:endAt,2:4),2) sum(LogF(startAt:endAt,2:5),2) sum(LogF(startAt:endAt,2:6),2) sum(LogF(startAt:endAt,2:7),2) sum(LogF(startAt:endAt,2:8),2)]);
|
||||
legend('timeMemoryUpdate', 'timeReactivations', 'timeLikelihoodCalculation', 'timePosteriorCalculation', 'timeHypothesesCreation', 'timeHypothesesValidation', 'timeRealTimeLimitReachedProcess', 'timeStatsCreation')
|
||||
title('Process time details')
|
||||
|
||||
figure
|
||||
subplot(211)
|
||||
plot(LogF(startAt:endAt,3));
|
||||
title('Reactivation time')
|
||||
subplot(212)
|
||||
plot(LogI(:,11),'.')
|
||||
|
||||
% -------------------------
|
||||
figure
|
||||
subplot(211)
|
||||
plot(LogI(startAt:endAt, 6));
|
||||
title('dictionary size')
|
||||
|
||||
subplot(212)
|
||||
plot([LogI(startAt:endAt, 9)/1000000 LogI(startAt:endAt, 10)/1000000]);
|
||||
title('Memory usage (in MB)')
|
||||
legend('Process', 'Database')
|
||||
% -------------------------
|
||||
|
||||
figure
|
||||
% subplot(211)
|
||||
H1 = plot(LogI(startAt:endAt,7));
|
||||
% hold on
|
||||
% H2 = plot(1:length(LogI(startAt:endAt,7)), ones(length(LogI(startAt:endAt,7)),1).*mean(LogI(startAt:endAt,7)), 'r--')
|
||||
%title('Working memory size')
|
||||
meanWM = mean(LogI(startAt:endAt,7))
|
||||
ylabel('WM size (locations)')
|
||||
xlabel('Location indexes')
|
||||
% set(H1,'color',[0.3 0.3 0.3])
|
||||
% set(H2,'color',[0 0 0])
|
||||
% subplot(212)
|
||||
% plot(LogI(startAt:endAt,6));
|
||||
meanDict = mean(LogI(startAt:endAt,6))
|
||||
% ylabel('Dictionary size')
|
||||
% xlabel('Location indexes')
|
||||
|
||||
meanWordsPerSign = mean(LogI(startAt:endAt,5))
|
||||
|
||||
|
||||
% -------------------------
|
||||
% Detected/Accepted/Rejected loop closures
|
||||
|
||||
% from VerifyEpipolarGeometry.h
|
||||
% UNDEFINED, 10
|
||||
% ACCEPTED, 11
|
||||
% NO_HYPOTHESIS, 12
|
||||
% MEMORY_IS_NULL, 13
|
||||
% NOT_ENOUGH_MATCHING_PAIRS, 14
|
||||
% EPIPOLAR_CONSTRAINT_FAILED, 15
|
||||
% NULL_MATCHING_SURF_SIGNATURES 16
|
||||
|
||||
figure;
|
||||
subplot(311)
|
||||
plot(LogF(:,10), '.')
|
||||
title('Highest posterior + lc accepted and rejected')
|
||||
hold on
|
||||
%rejected hypotheses
|
||||
y = LogF(:,10);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
x(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
plot(x,y, 'r.')
|
||||
%rejected (by ratio) hypotheses
|
||||
y = LogF(:,10);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
x(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
plot(x,y, 'b.')
|
||||
%Accepted hypotheses
|
||||
y = LogF(:,10);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
x(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
plot(x,y, 'g.')
|
||||
subplot(312)
|
||||
plot(LogI(:,2), '.')
|
||||
title('Id corresponding to highest posterior + lc accepted and rejected')
|
||||
hold on
|
||||
%rejected hypotheses
|
||||
y = LogI(:,2);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
x(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
plot(x,y, 'r.')
|
||||
%rejected (by ratio) hypotheses
|
||||
y = LogI(:,2);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
x(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
plot(x,y, 'b.')
|
||||
%Accepted hypotheses
|
||||
y = LogI(:,2);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
x(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
plot(x,y, 'g.')
|
||||
subplot(313)
|
||||
plot(LogI(:,5),'.')
|
||||
title('wordsNewSign')
|
||||
hold on
|
||||
%rejected hypotheses
|
||||
y = LogI(:,5);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
x(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11) = [];
|
||||
plot(x,y, 'r.')
|
||||
%rejected (by ratio) hypotheses
|
||||
y = LogI(:,5);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
x(LogI(startAt:endAt, 8) ~= 3) = [];
|
||||
plot(x,y, 'b.')
|
||||
%Accepted hypotheses
|
||||
y = LogI(:,5);
|
||||
x = 1:length(y);
|
||||
y(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
x(LogI(startAt:endAt, 8) < 10 | LogI(startAt:endAt, 8) > 11) = [];
|
||||
plot(x,y, 'g.')
|
||||
% %matched sign words
|
||||
% y = LogI(:,2);
|
||||
% x = 1:length(y);
|
||||
% mask = zeros(1,length(y));
|
||||
% y(LogI(startAt:endAt, 8) ~= 11) = [];
|
||||
% for i=1:length(y)
|
||||
% mask(y(i)) = 1;
|
||||
% end
|
||||
% y = LogI(:,5);
|
||||
% y(~mask) = [];
|
||||
% x(~mask) = [];
|
||||
% plot(x,y, 'c.')
|
||||
% %matched sign words for rejected
|
||||
% y = LogI(:,2);
|
||||
% x = 1:length(y);
|
||||
% mask = zeros(1,length(y));
|
||||
% y(LogI(startAt:endAt, 8) < 12) = [];
|
||||
% for i=1:length(y)
|
||||
% mask(y(i)) = 1;
|
||||
% end
|
||||
% y = LogI(:,5);
|
||||
% y(~mask) = [];
|
||||
% x(~mask) = [];
|
||||
% plot(x,y, 'm.')
|
||||
|
||||
lcAccepted = sum(LogI(startAt:endAt, 8) >= 10 & LogI(startAt:endAt, 8) <= 11)
|
||||
lcReactivated = sum(LogI(startAt:endAt, 12) == 1)
|
||||
lcRejected = sum(LogI(startAt:endAt, 8) > 11 | LogI(startAt:endAt, 8) == 3)
|
||||
lcRejectedNotEnoughPairs = sum(LogI(startAt:endAt, 8) == 14)
|
||||
lcRejectedEpipolarGeo = sum(LogI(startAt:endAt, 8) > 14)
|
||||
|
||||
%figure;
|
||||
%plot([1.0 * (LogI(startAt:endAt, 8) == 10) ...
|
||||
% 1.01 * (LogI(startAt:endAt, 8) == 11) ...
|
||||
% 1.02 * (LogI(startAt:endAt, 8) == 14) ...
|
||||
% 1.03 * (LogI(startAt:endAt, 8) == 15)], '.');
|
||||
%title('Reject loop reason')
|
||||
%legend('UNDEFINED', 'ACCEPTED', 'NOT ENOUGH MATCHING PAIRS', 'EPIPOLAR CONSTRAINT FAILED')
|
||||
|
||||
% -----------------
|
||||
% Squared matrix
|
||||
|
||||
|
||||
|
||||
%%
|
||||
%Precision-Recall graph
|
||||
|
||||
GroundTruth = [];
|
||||
if exist(GroundTruthFile, 'file')
|
||||
PR = getPrecisionRecall(LogI, LogF, GroundTruthFile, 0.03);
|
||||
|
||||
Precision = PR(:,1);
|
||||
Recall = PR(:,2);
|
||||
PrecisionVerified = PR(:,3);
|
||||
RecallVerified = PR(:,4);
|
||||
|
||||
%plot the Precision-Recall
|
||||
figure
|
||||
plot([Recall RecallVerified], [Precision PrecisionVerified])
|
||||
legend('Without verification', 'With verification')
|
||||
title('Precision - Recall')
|
||||
xlabel('Recall (%)')
|
||||
ylabel('Precision (%)')
|
||||
end
|
||||
|
||||
%%
|
||||
% count = 0;
|
||||
% for i=2:length(LogF(:,10))
|
||||
% if(LogF(i,10) > 0.45 && LogF(i,10) < LogF(i-1,10)*0.9)
|
||||
% display(['i=' num2str(i) ' with=' num2str(LogI(i,2)) ' ratio=' num2str(LogF(i,10)/LogF(i-1,10))])
|
||||
% count = count +1;
|
||||
% end
|
||||
% end
|
||||
% count
|
||||
|
||||
%%
|
||||
% figure
|
||||
% hold on
|
||||
% K=100;
|
||||
% %plot(1./(K*LogF(:,15)), 'r')
|
||||
% %plot(log10(1./(LogF(:,15))), 'c')
|
||||
% scale=1;
|
||||
% %plot(log10(1./(LogF(:,15))).^2 ./ ((LogF(:,12)-LogF(:,15))./LogF(:,14)), 'k')
|
||||
% %plot(log10(1./(LogF(:,15))), 'm')
|
||||
% plot((LogF(:,12)-LogF(:,15))./LogF(:,14), 'g')
|
||||
% plot([0, length(LogF(:,15))], [1 1], 'k:')
|
||||
% plot(LogF(:,11), 'b')
|
||||
% %legend(['K=' num2str(K)], 'ln', 'ln scaled', 'log10', 'max sim', '1', 'Vp likelihood')
|
||||
@@ -1,109 +0,0 @@
|
||||
function [ PR ] = getPrecisionRecall( LogI, LogF, GT_file, LoopThr )
|
||||
%GETPRECISIONRECALL Calculate the precision-recall results from the log
|
||||
%files of RTAB-Map and a Ground Truth file (a bmp).
|
||||
% PR(:,1) = Precision
|
||||
% PR(:,2) = Recall
|
||||
% PR(:,3) = Precision with verification
|
||||
% PR(:,4) = Recall with verification
|
||||
%
|
||||
% LogI: The 'LogI.txt' generated file
|
||||
% LogF: The 'LogF.txt' generated file
|
||||
% GT_file: The related Ground truth file of the dataset ('GT.bmp')
|
||||
% LoopThr: Display false positives over the loop thr (>=0.0 && < 1.0)
|
||||
|
||||
GroundTruth = [];
|
||||
if exist(GT_file, 'file')
|
||||
display('--- getPrecisionRecall ---');
|
||||
display(['Loading GroundTruth ''' GT_file ''' ...']);
|
||||
GroundTruth = imread(GT_file);
|
||||
else
|
||||
error(['The ground truth ''' GT_file '''doesn''t exist.'])
|
||||
end
|
||||
|
||||
if ~isempty(GroundTruth)
|
||||
%display('Calculating Precision-Recall graph')
|
||||
%figure
|
||||
%imshow(GroundTruth)
|
||||
%title('GroundTruth')
|
||||
|
||||
if size(GroundTruth, 1) ~= length(LogF(:,1)) || size(GroundTruth, 1) ~= length(LogI(:,1))
|
||||
error(['The ground truth size doesn''t match the log files (LogI=' num2str(length(LogI(:,1))) ', LogF=' num2str(length(LogF(:,1))) ', GT=' num2str(size(GroundTruth, 1)) ')'])
|
||||
end
|
||||
|
||||
|
||||
%[highestHypot, CorrespondingID, GT, Accepted, Good, Index, UnderLoopRatio] descending order
|
||||
lc = [LogF(:,10) LogI(:,2) sum(GroundTruth == 255, 2)>0 (LogI(:, 8) == 10 | LogI(:, 8) == 11) zeros(length(LogI(:,1)),1) (1:length(LogF(:,10)))' LogI(:, 8) == 3];
|
||||
|
||||
%eliminate loops on diagonal
|
||||
ignored = 0;
|
||||
for i=1:length(lc)
|
||||
index = find(GroundTruth(:,i) > 0 & GroundTruth(:,i) < 255);
|
||||
if ~isempty(index)
|
||||
row = GroundTruth(index(1), :);
|
||||
if lc(i,2) >= min(index) && lc(i,2) <= max(index)
|
||||
display(['i=' NUM2STR(i) ' loop=' NUM2STR(LogI(i,2)) ' min(index)=' NUM2STR(min(index)) ' max(index)' NUM2STR(max(index))])
|
||||
lc(i,1) = 0;
|
||||
ignored = ignored + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
lc = sortrows(lc, -1);
|
||||
|
||||
GT_total_positives = sum(sum(GroundTruth == 255, 2) > 0)
|
||||
|
||||
%figure
|
||||
%plot(sum(GroundTruth > 0, 2)>0)
|
||||
%title('Ground truth (timeline)')
|
||||
|
||||
sizeNonZero = sum(lc(:,1) > 0);
|
||||
|
||||
PR = zeros(sizeNonZero, 4);
|
||||
for i=1:length(lc)
|
||||
if lc(i,1) == 0
|
||||
break;
|
||||
end
|
||||
|
||||
id = lc(i,2);
|
||||
|
||||
if id && sum(GroundTruth(lc(i,6), id)) > 0
|
||||
lc(i,5) = 1;
|
||||
end
|
||||
|
||||
PR(i,2) = sum(lc(1:i,5) & ~lc(1:i,7) & lc(1:i,2))/GT_total_positives;
|
||||
PR(i,1) = sum(lc(1:i,5) & ~lc(1:i,7) & lc(1:i,2)) / sum(~lc(1:i, 7) & lc(1:i,2));
|
||||
|
||||
%PR(i,2) = sum(lc(1:i,5))/GT_total_positives;
|
||||
%PR(i,1) = sum(lc(1:i,5)) / i;
|
||||
|
||||
PR(i,4) = sum(lc(1:i,4) & lc(1:i,5))/GT_total_positives;
|
||||
PR(i,3) = sum(lc(1:i,4) & lc(1:i,5)) / sum(lc(1:i,4));
|
||||
|
||||
if ~lc(i,5) && ~lc(i,7) && id && lc(i,1) >= LoopThr
|
||||
display(['False positive! id=' num2str(lc(i,6)) ' with old=' num2str(id) ' (p=' num2str(lc(i,1)) ')'] )
|
||||
end
|
||||
|
||||
if lc(i,4) ~= lc(i,5) && lc(i,4)
|
||||
display(['False positive! (v) id=' num2str(lc(i,6)) ' with old=' num2str(id) ' (p=' num2str(lc(i,1)) ')'] )
|
||||
end
|
||||
end
|
||||
|
||||
index = find(PR(:,1) == 1);
|
||||
if ~isempty(index)
|
||||
maxRecall = PR(index(end),2) * 100;
|
||||
display(['Recall max (Precision=100%) = ' num2str(maxRecall) '% (p=' num2str(lc(index(end),1)) '), accepted=' num2str(sum(lc(1:index(end),5) & ~lc(1:index(end),7) & lc(1:index(end),2)))])
|
||||
else
|
||||
display('Recall max (Precision=100%) = 0')
|
||||
end
|
||||
indexV = find(PR(:,3) == 1);
|
||||
if ~isempty(indexV)
|
||||
maxRecallVerified = PR(indexV(end),4) * 100;
|
||||
display(['Recall max (Precision=100%, with verification) = ' num2str(maxRecallVerified) '% (p=' num2str(lc(indexV(end),1)) ')'])
|
||||
else
|
||||
display('Recall max (Precision=100%, with verification) = 0')
|
||||
end
|
||||
display(['ignored = ' num2str(ignored)])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user