%% DSO Paper: Figure 11. Results on TUM monoVO dataset.
clf
[ MallErrorsAlign, MallErrorsR, MallErrorsS, MallErrorsRMSE, MallErrorsA, MallErrorsE, Mn] = getSortedLOOPError( DSO_LOOP_FWD, [0:9] +1, DSO_LOOP_BWD );
[ OallErrorsAlign, OallErrorsR, OallErrorsS, OallErrorsRMSE, OallErrorsA, OallErrorsE, On] = getSortedLOOPError( ORB_LOOP_FWD, [0:9] +1, ORB_LOOP_BWD );
[ MallErrorsAlign_RT, MallErrorsR_RT, MallErrorsS_RT, MallErrorsRMSE_RT, MallErrorsA_RT, MallErrorsE_RT, Mn_RT] = getSortedLOOPError( DSO_LOOP_RT, [0:9] + 1 );
[ OallErrorsAlign_RT, OallErrorsR_RT, OallErrorsS_RT, OallErrorsRMSE_RT, OallErrorsA_RT, OallErrorsE_RT, On_RT] = getSortedLOOPError( ORB_LOOP_RTFIX, [0:9] +1 );
[ MallErrorsAlign_RT2, MallErrorsR_RT2, MallErrorsS_RT2, MallErrorsRMSE_RT2, MallErrorsA_RT2, MallErrorsE_RT2, Mn_RT2] = getSortedLOOPError( DSO_LOOP_RT, [10:19]+1 );
steps=1:1:10;
subplot(1,3,1)
hold on
semilogx(MallErrorsAlign,500*(1:Mn)/Mn,'blue','LineWidth',2)
semilogx(MallErrorsAlign_RT,500*(1:Mn_RT)/Mn_RT,'blue','LineWidth',2,'LineStyle','--')
semilogx(MallErrorsAlign_RT2,500*(1:Mn_RT2)/Mn_RT2,'blue','LineWidth',1,'LineStyle','-')
plot(steps,findXVec(500*(1:Mn_RT2)/Mn_RT2, MallErrorsAlign_RT2,steps),'blue','LineWidth',1,'LineStyle','none', 'Marker','o')
semilogx(OallErrorsAlign,500*(1:On)/On,'red','LineWidth',2)
semilogx(OallErrorsAlign_RT,500*(1:On_RT)/On_RT,'red','LineWidth',2,'LineStyle','--')
axis([0 10 0 500]);
grid on
set(gca, 'XTick',[0:2:10])
title('alignment error')
subplot(1,3,2)
steps=1:2:20;
hold on
semilogx(MallErrorsR,500*(1:Mn)/Mn,'blue','LineWidth',2)
semilogx(MallErrorsR_RT,500*(1:Mn_RT)/Mn_RT,'blue','LineWidth',2,'LineStyle','--')
semilogx(MallErrorsR_RT2,500*(1:Mn_RT2)/Mn_RT2,'blue','LineWidth',1,'LineStyle','-')
plot(steps,findXVec(500*(1:Mn_RT2)/Mn_RT2, MallErrorsR_RT2,steps),'blue','LineWidth',1,'LineStyle','none', 'Marker','o')
semilogx(OallErrorsR,500*(1:On)/On,'red','LineWidth',2)
semilogx(OallErrorsR_RT,500*(1:On_RT)/On_RT,'red','LineWidth',2,'LineStyle','--')
axis([0 20 0 500]);
grid on
set(gca, 'XTick',[0:4:20])
title('rotation error')
subplot(1,3,3)
steps=1:0.5:4;
hold on
semilogx(MallErrorsS,500*(1:Mn)/Mn,'blue','LineWidth',2)
semilogx(MallErrorsS_RT,500*(1:Mn_RT)/Mn_RT,'blue','LineWidth',2,'LineStyle','--')
semilogx(MallErrorsS_RT2,5000+500*(1:Mn_RT2)/Mn_RT2,'blue','LineWidth',1,'LineStyle','-', 'Marker','o')
semilogx(OallErrorsS,500*(1:On)/On,'red','LineWidth',2)
semilogx(OallErrorsS_RT,500*(1:On_RT)/On_RT,'red','LineWidth',2,'LineStyle','--')
semilogx(MallErrorsS_RT2,500*(1:Mn_RT2)/Mn_RT2,'blue','LineWidth',1,'LineStyle','-')
plot(steps,findXVec(500*(1:Mn_RT2)/Mn_RT2, MallErrorsS_RT2,steps),'blue','LineWidth',1,'LineStyle','none', 'Marker','o')
legend('DSO', 'DSO (real-time)', 'DSO (LQ, 5x real-time)', 'ORB-SLAM', 'ORB-SLAM (real-time)','Location','southeast')
axis([1 4 0 500]);
grid on
set(gca, 'XTick',[1:0.5:4])
title('scale error')
%% DSO: Figure 14. Photometric Calibration.
clf
idx_default = 0:9; % default.
idx_allFix = 50:54; % no exposure correction whatsoever, AB FIX
idx_noABPrior = 45:49; % full correction, no prior on AB (unknown exposure)
idx_noVignette = 40:44; % no vignette correction, no prior on AB
idx_nogamma = 35:39; % no vignette & no gamma correction, no prior on AB
idx_Cfix = 255:259; % full correction, AB FIX
idx_Cmfix = 260:264; % full correction, AB MOSTLY FIX
[ err_default, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_default + 1, DSO_LOOP_BWD );
n_default = size(err_default,1);
[ err_noABPrior, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_noABPrior + 1, DSO_LOOP_BWD );
n_noABPrior = size(err_noABPrior,1);
[ err_noVignette, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_noVignette + 1, DSO_LOOP_BWD );
n_noVignette = size(err_noVignette,1);
[ err_nogamma, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_nogamma + 1, DSO_LOOP_BWD );
n_nogamma = size(err_nogamma,1);
[ err_allFix, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_allFix + 1, DSO_LOOP_BWD );
n_allFix = size(err_allFix,1);
[ err_Cfix, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_Cfix + 1 , DSO_LOOP_BWD );
n_Cfix = size(err_Cfix,1);
[ err_Cmfix, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_Cmfix + 1, DSO_LOOP_BWD );
n_Cmfix = size(err_Cmfix,1);
clf
hold on
plot(err_default,500*(1:n_default)/n_default,'red','LineWidth',2)
plot(err_noABPrior,500*(1:n_noABPrior)/n_noABPrior,'blue','LineWidth',2)
plot(err_noVignette,500*(1:n_noVignette)/n_noVignette,'green','LineWidth',2)
plot(err_nogamma,500*(1:n_nogamma)/n_nogamma,'yellow','LineWidth',2)
plot(err_allFix,500*(1:n_allFix)/n_allFix,'black','LineWidth',2)
axis([0 10 0 500]);
grid on
legend('full calib.', 'unknown t', 'unknown t, V', 'unknown t, V, G', 'brightness cons.','Location','eastoutside');
set(gca, 'XTick',[0:1:10])
%% DSO: Figure 15. Amount of Data Used.
clf
idx_50 = 275:279;
idx_100 = 270:274;
idx_200 = 265:269;
idx_300 = 205:209;
idx_500 = 200:204;
idx_700 = 195:199;
idx_1000 = 55:59;
idx_1500 = 60:64;
idx_3000 = 65:69;
idx_6000 = 70:74;
idx_10000 = 75:79;
idx_kf4 = 280:284;
idx_kf5 = 80:84;
idx_kf6 = 185:189;
idx_kf9 = 85:89;
idx_kf11 = 190:194;
idx_fixWindow = 285:289;
[ err_default, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_default + 1, DSO_LOOP_BWD);
n_default = size(err_default,1);
[ err_50, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_50 + 1, DSO_LOOP_BWD );
n_50 = size(err_50,1);
[ err_100, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_100 + 1, DSO_LOOP_BWD );
n_100 = size(err_100,1);
[ err_200, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_200 + 1, DSO_LOOP_BWD );
n_200 = size(err_200,1);
[ err_300, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_300 + 1, DSO_LOOP_BWD );
n_300 = size(err_300,1);
[ err_500, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_500 + 1, DSO_LOOP_BWD );
n_500 = size(err_500,1);
[ err_700, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_700 + 1, DSO_LOOP_BWD );
n_700 = size(err_700,1);
[ err_1000, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_1000 + 1, DSO_LOOP_BWD );
n_1000 = size(err_1000,1);
[ err_1500, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_1500 + 1, DSO_LOOP_BWD );
n_1500 = size(err_1500,1);
[ err_3000, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_3000 + 1, DSO_LOOP_BWD );
n_3000 = size(err_3000,1);
[ err_6000, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_6000 + 1, DSO_LOOP_BWD );
n_6000 = size(err_6000,1);
[ err_10000, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_10000 + 1, DSO_LOOP_BWD );
n_10000 = size(err_10000,1);
[ err_kf4, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_kf4 + 1, DSO_LOOP_BWD );
n_kf4 = size(err_kf4,1);
[ err_kf5, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_kf5 + 1, DSO_LOOP_BWD );
n_kf5 = size(err_kf5,1);
[ err_kf6, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_kf6 + 1, DSO_LOOP_BWD );
n_kf6 = size(err_kf6,1);
[ err_kf9, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_kf9 + 1, DSO_LOOP_BWD );
n_kf9 = size(err_kf9,1);
[ err_kf11, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_kf11 + 1, DSO_LOOP_BWD );
n_kf11 = size(err_kf11,1);
[ err_fixWindow, ~, ~, ~] = getSortedLOOPError( DSO_LOOP_FWD, idx_fixWindow + 1, DSO_LOOP_BWD );
n_fixWindow = size(err_fixWindow,1);
subplot(1,2,1)
C = jet(8); C=C(end:-1:1,:);
hold on
semilogx(err_50,500*(1:n_50)/n_50,'Color',C(1,:)','LineWidth',2)
semilogx(err_100,500*(1:n_100)/n_100,'Color',C(2,:)','LineWidth',2)
semilogx(err_200,500*(1:n_200)/n_200,'Color',C(3,:)','LineWidth',2)
semilogx(err_500,500*(1:n_500)/n_500,'Color',C(4,:)','LineWidth',2)
semilogx(err_1000,500*(1:n_1000)/n_1000,'Color',C(5,:)','LineWidth',2)
semilogx(err_default,500*(1:n_default)/n_default,'Color',C(6,:)','LineWidth',2)
semilogx(err_6000,500*(1:n_6000)/n_6000,'Color',C(7,:)','LineWidth',2)
semilogx(err_10000,500*(1:n_10000)/n_10000,'Color',C(8,:)','LineWidth',2)
axis([0 10 0 500]);
grid on
legend('N_p=50', 'N_p=100'