%SCRIPT_BuildDetectionPRCurves
%

ToyotaRoot = '/cbcl/scratch01/bileschi/PrecomputedFeatures/StreetScenes/AppearanceDetector/ToyotaAppObjDet/';
ToyotaTemplate = 'ToyotaDet_%.5d.mat'
ToyotaRoot2 = '/cbcl/scratch01/bileschi/ObjectDetectors/ToyotaResults'
ToyotaTemplate2 = 'Detections_%.5d.mat';
GrayRoot = '/cbcl/scratch01/bileschi/PrecomputedFeatures/StreetScenes/AppearanceDetector/GrayscaleAppObjDet/';
GrayTemplate = 'GrayscaleDet_%.5d.mat'

load /cbcl/scratch01/bileschi/TextureRec/First_Train_Indicies.mat %--> TTS
load DA250;%-->DA250_bicycle,DA250_car,DA250_pedestrian
clear objname;
objname{1} = 'car';
objname{2} = 'pedestrian';
objname{3} = 'bicycle';
Test = setdiff(1:300,TTS.Train);
TrueData{1} = DA250_car;
TrueData{2} = DA250_pedestrian;
TrueData{3} = DA250_bicycle;

for i = 2
  DLTest_Toyota = PROCEDURE_CollectDetectionList(fullfile(ToyotaRoot,objname{i}),ToyotaTemplate,Test,1);
  DLTest_Toyota2 = PROCEDURE_CollectDetectionList(ToyotaRoot2,ToyotaTemplate2,Test,1);
  DLTest_Gray = PROCEDURE_CollectDetectionList(fullfile(GrayRoot,objname{i}),GrayTemplate,Test,1);
  [PR_Toyota{i}.P,PR_Toyota{i}.R] = PrecisionRecallOfDetectionArrays(DLTest_Toyota,TrueData{i});
  [PR_Toyota2{i}.P,PR_Toyota2{i}.R] = PrecisionRecallOfDetectionArrays(DLTest_Toyota2,TrueData{i});
  [PR_Gray{i}.P,PR_Gray{i}.R] = PrecisionRecallOfDetectionArrays(DLTest_Gray,TrueData{i});
end

plot(PR_Toyota{i}.R,PR_Toyota{i}.P,'r-');
hold on
plot(PR_Toyota2{i}.R,PR_Toyota2{i}.P,'r:');
plot(PR_Gray{i}.R,PR_Gray{i}.P,'k-');
axis([0 1 0 1]);

for iObjname = 1:3
subplot(2,2,iObjname);
plot(ROC_gray{iObjname}.recall, ROC_gray{iObjname}.precision, 'k-');
 hold on                                               
 plot(ROC_toyota{iObjname}.recall, ROC_toyota{iObjname}.precision, 'r-');
end