clc
clear
close all
addpath(genpath('.'));

db = 'ALL'; 

path = 'D:\\Data\\TB-MEEM-Compatible\\';

%type_rect = {'BSBT','CCT','CPF','CSK','CT','CXT','DFT','FOT','FRAG','KMS','LCT','LOT','LSHT','LSK','MEEM','MIL','MS','OAB','PD','RS','SBT','SMS','STRUCK','TLD','TM','VR','VTD','VTS', ...
    %'MUSTer','CCOT','SRDCF','DeepSRDCF','DSST','MQT','MTMVTLAD','MTMVTLS','DLSSVM','Scale_DLSSVM','SFC3','SFC5','STAPLE'}; %ALL RECT TYPE OTB13
%type_rect = [type_rect,{'UST','QBT','QBST','CMT'}];
type_rect = {'DEDT','CCOT','STAPLE','MUSTer','SRDCF','MEEM','STRUCK','TLD'}; % rivals for this experiment only
%type_rect = {'DEDT-0.00','DEDT-0.20','DEDT-0.43','DEDT-0.50','DEDT-0.80','DEDT-1.00','DEDT-rand'}; % delta experiment only
%type_rect = {'DEDT','DEDT-art','DEDT-bag'}; % diversity experiment only
%type_rect = {'DEDT','DEDT-real'}; % real_data experiment only
%type_rect = {'DEDT','RET','OAB','BSBT','MIL'}; %ensemble

IV=  {'Basketball', 'Car4', 'CarDark', 'Coke', 'David', 'Doll', 'FaceOcc2', 'Fish', 'Ironman', 'Lemming', 'Liquor', 'Matrix', 'Mhyang', 'MotorRolling', 'Shaking', 'Singer1', 'Singer2', 'Skating1', 'Skiing', 'Soccer', 'Sylvester', 'Tiger1', 'Tiger2', 'Trellis', 'Woman'};
SV=  {'Boy', 'Car4', 'CarScale', 'Couple', 'Crossing', 'David', 'Dog1', 'Doll', 'Dudek', 'FleetFace', 'Freeman1', 'Freeman3', 'Freeman4', 'Girl', 'Ironman', 'Lemming', 'Liquor', 'Matrix', 'MotorRolling', 'Shaking', 'Singer1', 'Skating1', 'Skiing', 'Soccer', 'Trellis', 'Walking', 'Walking2', 'Woman'};%
OCC= {'Basketball', 'Bolt', 'CarScale', 'Coke', 'David', 'David3', 'Doll', 'Dudek', 'FaceOcc1', 'FaceOcc2', 'Football', 'Freeman4', 'Girl', 'Ironman', 'Lemming', 'Liquor', 'Matrix', 'Singer1', 'Skating1', 'Soccer', 'Subway', 'Suv', 'Tiger1', 'Tiger2', 'Walking', 'Walking2', 'Woman'};%
DEF= {'Basketball', 'Bolt', 'Couple', 'Crossing', 'David', 'David3', 'Dudek', 'FleetFace', 'Mhyang', 'Singer2', 'Skating1', 'Skiing', 'Subway', 'Tiger1', 'Tiger2', 'Walking', 'Woman'};%
MB=  {'Boy', 'David', 'Deer', 'FleetFace', 'Ironman', 'Jumping', 'Liquor', 'MotorRolling', 'Soccer', 'Tiger1', 'Tiger2', 'Woman'};%
FM=  {'Boy', 'CarScale', 'Coke', 'Couple', 'Deer', 'Dudek', 'FleetFace', 'Ironman', 'Jumping', 'Lemming', 'Liquor', 'Matrix', 'MotorRolling', 'Soccer', 'Tiger1', 'Tiger2', 'Woman'};%
IPR= {'Bolt', 'Boy', 'CarScale', 'Coke', 'David', 'David2', 'Deer', 'Dog1', 'Doll', 'Dudek', 'FaceOcc2', 'FleetFace', 'Football', 'Football1', 'Freeman1', 'Freeman3', 'Freeman4', 'Girl','Ironman', 'Matrix', 'MotorRolling', 'MountainBike', 'Shaking', 'Singer2', 'Skiing', 'Soccer', 'Suv', 'Sylvester', 'Tiger1', 'Tiger2', 'Trellis'};%
OPR= {'Basketball', 'Bolt', 'Boy', 'CarScale', 'Coke', 'Couple', 'David', 'David2', 'David3', 'Dog1', 'Doll', 'Dudek', 'FaceOcc2', 'FleetFace', 'Football', 'Football1', 'Freeman1', 'Freeman3', 'Freeman4', 'Girl', 'Ironman', 'Lemming', 'Liquor', 'Matrix', 'Mhyang', 'MountainBike', 'Shaking', 'Singer1', 'Singer2', 'Skating1', 'Skiing', 'Soccer', 'Sylvester', 'Tiger1', 'Tiger2', 'Trellis', 'Woman'};%
OV=  {'Dudek', 'Ironman', 'Lemming', 'Liquor', 'Suv', 'Tiger2'};%
BC=  {'Basketball','CarDark', 'Couple', 'Crossing', 'David3', 'Deer', 'Dudek', 'Football', 'Football1', 'Ironman', 'Liquor', 'Matrix', 'Mhyang', 'MotorRolling', 'MountainBike', 'Shaking', 'Singer2', 'Skating1', 'Soccer', 'Subway', 'Trellis'};%
LR=  {'Freeman3', 'Freeman4', 'Skiing', 'Walking'};%
ALL= find_videos (path);
RET= {'Basketball','David','FaceOcc2','Football','Girl','Shaking','Singer1','Singer2','Skating1','Soccer','Sylvester','Tiger1','Tiger2'};

videos = eval(db);
trackers = type_rect;

fprintf('Loading Results [');
for i = 1:length(videos)
    fn = videos{i};
    fprintf('-')
    gt_name = sprintf('%s%s\\%s\\groundtruth_rect.txt',path,fn,fn);
    
    % load gt
    fid = fopen(gt_name,'r');
    gt_cols  = textscan(fid,'%d,%d,%d,%d');
    if (isempty(gt_cols{2}))
        gt_cols  = textscan(fid,'%d %d %d %d');
    end
    fclose (fid);
    gt{i} = [gt_cols{1},gt_cols{2},gt_cols{3},gt_cols{4}];
    
    for j = 1:length(trackers)
        tr = trackers{j};
        load (sprintf('%s_%s.mat',fn,tr));
        
        r{i,j} = results{1,1};
    end
end
disp(']');

%draw_success_plot (trackers, videos, gt, r , db);
%draw_precision_plot (trackers, videos, gt, r , db);
%draw_cpe_plot (trackers, videos, gt, r);

% draw_sample_frames_bw (trackers, videos, gt, r, 'FaceOcc2' , [175,497,812], 'k' );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Walking2' , [50,134,142] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Deer' , [7,42,71] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Jumping' , [31,100,238], 'k' );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Girl' , [111,312,430], 'k' );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Ironman' , [14,32,56] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Singer1' , [121,321] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Shaking' , [13,60,339] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'CarDark' , [19,284] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Board' , [55,78,183,395,528,592]);
% draw_sample_frames_bw (trackers, videos, gt, r, 'Soccer' , [49,81,90] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Basketball' , [89,73,101] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'David3' , [19,26,46,78,86, 93] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Singer2' , [41,94] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'Skating1' , [9,18,62,100] );
% draw_sample_frames_bw (trackers, videos, gt, r, 'FaceOcc1' , [10,50,90] );


 %demo_video (trackers, videos, gt, r, {ALL{1:end}},[1]);
 %demo_video (trackers, videos, gt, r, {'Basketball'},[5]);
 %demo_video (trackers, videos, gt, r, {'Basketball'},[5]);