close all; clearvars;
%% Fig 7a
thresh = [20.2020  22.2222  24.2424  26.2626  28.2828  30.3030  32.3232  34.3434  36.3636  38.3838  40.4040  42.4242  44.4444  46.4646  48.4848  50.5051];
accuracies = [0.2693  0.2949  0.3205  0.3446  0.3666  0.3868  0.4062  0.4248  0.4435  0.4618  0.4799  0.4975  0.5145  0.5316  0.5485  0.5652; ...
              0.3688  0.3988  0.4266  0.4525  0.4768  0.4994  0.5212  0.5417  0.5613  0.5800  0.5975  0.6147  0.6308  0.6464  0.6623  0.6774; ...
              0.4121  0.4442  0.4744  0.5025  0.5289  0.5536  0.5770  0.5994  0.6201  0.6397  0.6582  0.6755  0.6916  0.7070  0.7213  0.7350; ...
              0.4416  0.4772  0.5101  0.5410  0.5699  0.5968  0.6212  0.6445  0.6660  0.6858  0.7049  0.7229  0.7394  0.7550  0.7697  0.7835 ];

colors = lines(size(accuracies,1));
ourMarkers = {'h','o','s','d'};
ourLineStyles = {'-','-','-','-'};
 
figure(1); hold on;
for i=1:size(accuracies,1)
    plot(thresh, accuracies(i,:), 'Color', colors(i,:),'MarkerFaceColor',colors(i,:), 'LineWidth', 1, 'LineStyle', ourLineStyles{i}, 'Marker', ourMarkers{i})
end
hold off
ylim([0.3, 1.0])
xlim([20 50])
title('Stereo dataset (12 seq.)')
legend('synth-only','synth+colorAug','synth+GANerated','synth+GANerated+ProjLayer','Location', 'northwest')
ax = gca;
ax.XLabel.String = 'Error Thresholds (mm)';
ax.YLabel.String = '3D PCK';

%% Fig 7b
thresh = [19.1919  22.2222  25.2525  28.2828  31.3131  34.3434  37.3737  40.4040  43.4343  46.4646  49.4949];
% proposed
accuracies = [0.7031  0.7323  0.7586  0.7831  0.8056  0.8249  0.8424  0.8586  0.8728  0.8859  0.8972; ...
              0.8713  0.9035  0.9271  0.9446  0.9574  0.9670  0.9741  0.9795  0.9833  0.9867  0.9895 ];
AUC = [0.8249  0.9653];

ourNames = {'Ours wo/St.','Ours w/St.'};
ourMarkers = {'*','h'};
ourLineStyles = {'-','-'};
colors = lines(5+size(accuracies,1));

% other methods
pso = [20, 0.322368421052632;
        25, 0.539473684210526;
        30, 0.674342105263158;
        35, 0.756578947368421;
        40, 0.809210526315789;
        45, 0.865131578947368;
        50, 0.894736842105263;];
icppso = [20 ,0.519736842105263;
        25, 0.644736842105263;
        30, 0.717105263157895;
        35, 0.773026315789474;
        40, 0.809210526315789;
        45, 0.848684210526316;
        50, 0.868421052631579];
chpr = [20, 0.565789473684211;
        25, 0.717105263157895;
        30, 0.822368421052632;
        35, 0.881578947368421;
        40, 0.914473684210526;
        45, 0.9375;
        50, 0.960526315789474];    
zb = [21.0526315789474, 0.869888888888889;
        23.6842105263158, 0.896873015873016;
        26.3157894736842, 0.916849206349206;
        28.9473684210526, 0.932142857142857;
        31.5789473684211, 0.943507936507937;
        34.2105263157895, 0.952753968253968;
        36.8421052631579, 0.959904761904762;
        39.4736842105263, 0.966047619047619;
        42.1052631578947, 0.971595238095238;
        44.7368421052632, 0.976547619047619;
        47.3684210526316, 0.980174603174603;
        50, 0.983277777777778];    
legendNames = {'PSO (AUC=0.709)', 'ICPPSO (AUC=0.748)', 'CHPR (AUC=0.839)', 'Z&B (AUC=0.948)'}; 

figure(2); hold on;
plot(pso(:, 1), pso(:, 2), 'Color', colors(1,:), 'LineWidth', 1,'Marker','o','LineStyle','-','MarkerFaceColor',colors(1,:))
plot(icppso(:, 1), icppso(:, 2), 'Color', colors(2,:), 'LineWidth', 1,'Marker','^','LineStyle','-','MarkerFaceColor',colors(2,:))
plot(chpr(:, 1), chpr(:, 2), 'Color', colors(3,:), 'LineWidth', 1,'Marker','s','LineStyle','-','MarkerFaceColor',colors(3,:))
plot(zb(:, 1), zb(:, 2), 'Color', colors(4,:), 'LineWidth', 1,'Marker','d','LineStyle','-','MarkerFaceColor',colors(4,:))
for i=1:size(accuracies,1)
    plot(thresh, accuracies(i,:), 'Color', colors(4+i,:), 'LineWidth', 1,'Marker',ourMarkers{i},'MarkerFaceColor',colors(4+i,:),'LineStyle',ourLineStyles{i})
    ourNames{i} = [ourNames{i},' (AUC=',num2str(AUC(i),'%.3f'),')'];
end
hold off
ylim([0.3, 1.0])
xlim([20 50])
title('Stereo dataset (2 seq.)')
legend([legendNames,ourNames],'Location', 'southeast')
ax = gca;
ax.XLabel.String = 'Error Thresholds (mm)';
ax.YLabel.String = '3D PCK';

%% Fig 7c
thresh = linspace(0, 30, 20);
% Zimmermann & Brox
zb = [0  0.0122  0.0468  0.1004  0.1613  0.2329  0.3119  0.3930  0.4735  0.5426  0.6061  0.6528  0.6943  0.7229  0.7472  0.7690  0.7870  0.8023  0.8164  0.8274; ...
      0  0.0168  0.0782  0.1781  0.2883  0.3848  0.4603  0.5098  0.5449  0.5679  0.5832  0.5981  0.6111  0.6245  0.6392  0.6504  0.6634  0.6720  0.6794  0.6912 ];
AUC_zb = [0.49  0.4427];
% proposed
accuracies = [0  0.0678  0.2481  0.4548  0.5956  0.6731  0.7189  0.7548  0.7820  0.8001  0.8115  0.8187  0.8247  0.8300  0.8378  0.8476  0.8574  0.8651  0.8728  0.8781; ...
              0  0.0443  0.1617  0.3015  0.4451  0.5335  0.5872  0.6198  0.6450  0.6662  0.6809  0.7033  0.7184  0.7352  0.7448  0.7571  0.7650  0.7739  0.7790  0.7886 ];
AUC = [0.6434  0.5406];

colors = [0    0.4470    0.7410; ...
    74/255, 183/255, 1; ...
    240/255, 158/255, 123/255; ...
    0.8500    0.3250    0.0980];
figure(3); hold on;
plot(thresh, zb(1,:), 'Color',colors(2,:), 'LineWidth', 1,'Marker','s','LineStyle','-','MarkerFaceColor',colors(2,:))
plot(thresh, accuracies(1,:), 'Color',colors(1,:), 'LineWidth', 1,'Marker','o','LineStyle','-','MarkerFaceColor',colors(1,:))
plot(thresh, zb(2,:), 'Color',colors(3,:), 'LineWidth', 1,'Marker','d','LineStyle','-','MarkerFaceColor',colors(3,:))
plot(thresh, accuracies(2,:), 'Color',colors(4,:), 'LineWidth', 1,'Marker','h','LineStyle','-','MarkerFaceColor',colors(4,:))
hold off
ylim([0.0, 1.0])
title('Dexter+Object | EgoDexter')
legend(['D+O: Z&B (AUC=',num2str(AUC_zb(1),'%.2f'),')'],['D+O: Ours (AUC=',num2str(AUC(1),'%.2f'),')'],['ED: Z&B (AUC=',num2str(AUC_zb(2),'%.2f'),')'],['ED: Ours (AUC=',num2str(AUC(2),'%.2f'),')'],'Location','southeast')
ax = gca;
ax.XLabel.String = 'Error Thresholds (pixels)';
ax.YLabel.String = '2D PCK';

%% Supp doc, Fig 1
thresh = [0  5.0505  10.1010  15.1515  20.2020  25.2525  30.3030  35.3535  40.4040  45.4545  50.5051  55.5556  60.6061  65.6566  70.7071  75.7576  80.8081  85.8586  90.9091  95.9596];
% Sridhar et al. (RGB-D)
sridhar = [0  0.0604  0.2674  0.4908  0.6830  0.7981  0.8676  0.9082  0.9349  0.9530  0.9650  0.9718  0.9775  0.9820  0.9869  0.9910  0.9949  0.9967  0.9980  0.9983];
AUC_sridhar = 0.8143;
% proposed (RGB only)
accuracies = [0  0.0148  0.0764  0.1669  0.2611  0.3507  0.4325  0.5026  0.5641  0.6089  0.6523  0.6909  0.7249  0.7539  0.7782  0.8018  0.8213  0.8411  0.8601  0.8776; ...
              0  0.0339  0.1562  0.2887  0.4092  0.5084  0.6029  0.6852  0.7566  0.8080  0.8463  0.8769  0.9016  0.9187  0.9300  0.9396  0.9467  0.9536  0.9625  0.9698 ];
AUC = [0.5579  0.6963];

colors = [0    0.4470    0.7410; ...
    74/255, 183/255, 1; ...
    240/255, 158/255, 123/255; ...
    0.8500    0.3250    0.0980];
figure(4); hold on;
plot(thresh, sridhar, 'Color',colors(4,:), 'LineWidth', 1,'Marker','o','LineStyle','-','MarkerFaceColor',colors(4,:))
plot(thresh, accuracies(2,:), 'Color',colors(2,:), 'LineWidth', 1,'Marker','d','LineStyle','-','MarkerFaceColor',colors(2,:))
plot(thresh, accuracies(1,:), 'Color',colors(1,:), 'LineWidth', 1,'Marker','s','LineStyle','-','MarkerFaceColor',colors(1,:))
hold off
ylim([0.0, 1.0])
title('Dexter+Object')
legend(['Sridhar et al. (RGB-D) (AUC=',num2str(AUC_sridhar,'%.2f'),')'],['Ours modulo depth (RGB) (AUC=',num2str(AUC(2),'%.2f'),')'],['Ours (RGB) (AUC=',num2str(AUC(1),'%.2f'),')'],'Location','southeast')
ax = gca;
ax.XLabel.String = 'Error Thresholds (mm)';
ax.YLabel.String = '3D PCK';