Matlab Code for Visualize the Tracking Results of OTB100 dataset
Matlab Code for Visualize the Tracking Results of OTB100 dataset
2018-11-12 17:06:21
1 %把所有tracker的结果画在一张图上,结果保存在当前目录下的trackingResultsDisplay下
2 clc; close all; clear all;
3 dataPath = 'C:\Users\WANG XIAO\Desktop\Tracking_evaluation\OTB100_benchmark\Benchmark\';
4 trackerResultsPath='C:\Users\WANG XIAO\Desktop\Tracking_evaluation\PlotErr_OTBdataset\BBresults\';
5 sequencePath=dataPath;
6 saveBasePath='C:\Users\WANG XIAO\Desktop\demo_tracking_results\';
7 sequences=dir(dataPath);
8 sequences=sequences(3:end);
9 sequences={sequences.name};
10
11 12 13
14 tracker={ 'CSRDCF', 'SRDCF', 'ECO', 'CCOT', 'pyMDNetBaseline' };
15
16 % edgeColor={'r', 'g', 'b', 'y', 'k', 'm', 'c', 'g', 'b', 'y', 'k', 'm'};
17 edgeColor(:,:,1)=[1,0,0]; edgeColor(:,:,2)=[0,0,1]; edgeColor(:,:,3)=[0,1,0];
18 edgeColor(:,:,4)=[0,1,1]; edgeColor(:,:,5)=[1,0,1]; edgeColor(:,:,6)=[0,0,0];
19 edgeColor(:,:,7)=[1,1,1];
20
21
22 edgeColor(:,:,8)=[0,1,0]; edgeColor(:,:,9)=[0,1,1];
23 edgeColor(:,:,10)=[1,0,1]; edgeColor(:,:,11)=[0,0,0]; edgeColor(:,:,12)=[1,0.5,0];
24 edgeColor(:,:,13)=[0.5,0.5,0]; edgeColor(:,:,14)=[0,0,1]; edgeColor(:,:,15)=[0,1,0];
25 lineStyle={'-','-','-','-','-','-','-',};
26
27 %% ####################################################
28 seqIndexList = {51, 64, 72}; %% set the video index you want to shown.
29
30
31 for seqIndex=1:length(seqIndexList)
32 trackerResult=[];
33 sequence=sequences{seqIndexList{seqIndex}};
34
35
36 if(isdir(saveBasePath)==0),
37 mkdir(saveBasePath);
38 end
39
40
41
42 savingPath=[saveBasePath sequence '/'];
43 if(isdir(savingPath)==0),
44 mkdir(savingPath);
45 mkdir([savingPath 'v/']);
46 mkdir([savingPath 'i/']);
47
48 end
49 savingPath;
50
51
52
53 for trackerIndex=1:length(tracker),
54 try
55 trackerResult(:,:,trackerIndex)=dlmread([trackerResultsPath tracker{trackerIndex} '_' sequence '.txt']);
56 catch
57 trackerResult(:,:,trackerIndex)=dlmread([trackerResultsPath sequence '_' tracker{trackerIndex} '.txt']);
58 end
59
60 end
61
62 frames_v=dir([sequencePath sequence '/img/*.jpg']);
63 frames_i=dir([sequencePath sequence '/img/*.jpg']);
64 if(isempty(frames_v)==1),
65 frames_v=dir([sequencePath sequence '/img/*.jpg']);
66 end
67
68 if(isempty(frames_i)==1),
69 frames_i=dir([sequencePath sequence '/img/*.jpg']);
70 end
71
72 frames_v={frames_v.name};
73 frames_i={frames_i.name};
74
75
76 77
78 bb=[ trackerResult(:,1,:), trackerResult(:,2,:) , trackerResult(:,3,:), trackerResult(:,4,:) ] ;
79
80
81
82
83 % for the visible images
84 for frameIndex=1:length(frames_v),
85 im=imread([sequencePath sequence '/img/' frames_v{frameIndex}]);
86 imshow(uint8(im));
87 for trackerIndex=1:length(tracker),
88 if ~isempty(strfind(tracker{trackerIndex},'_i'))==1, 89 continue;
90 end
91 tracker{trackerIndex}
92
93 disp(['==>> frameIndex: ', num2str(frameIndex), ' ==>> trackerIndex: ', num2str(trackerIndex)]);
94 disp(['==>> bb: ', num2str(size(bb))]);
95 bbtemp=bb(frameIndex,:,trackerIndex);
96
97 if bbtemp(3)<=0,
98 bbtemp(3)=1;
99 bb(frameIndex,:,trackerIndex)=bbtemp;
100 end
101 if bbtemp(4)<=0,
102 bbtemp(4)=1;
103 bb(frameIndex,:,trackerIndex)=bbtemp;
104 end
105
106 if(bb(frameIndex,1,trackerIndex)>0||bb(frameIndex,2,trackerIndex)>0||...
107 bb(frameIndex,3,trackerIndex)>0||bb(frameIndex,4,trackerIndex)>0),
108 rectangle('Position',bb(frameIndex,:,trackerIndex),'LineWidth',2,'EdgeColor',edgeColor(:,:,trackerIndex),'LineStyle',lineStyle{trackerIndex});
109 end
110 end
111
112
113
114 hold on;
115 text(10, 30, strcat('#',num2str(frameIndex)), 'Color','y', 'FontWeight','bold', 'FontSize',30);
116 set(gca,'position',[0 0 1 1]);
117 pause(0.00001);
118 hold off;
119 imgName=sprintf('%04d.jpg',frameIndex);
120 saveas(gca,[savingPath 'v/' imgName]);
121 t1=imread([savingPath 'v/' imgName]);
122 t1=imresize(t1,[272 640]);
123 % imwrite(t1, [savingPath 'v/' imgName]);
124
125 end
126
127 end
Stay Hungry,Stay Foolish ...