-
Notifications
You must be signed in to change notification settings - Fork 4
/
main_running.m
185 lines (139 loc) · 4.82 KB
/
main_running.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
close all
clear
clc
warning off all;
addpath('./util');
% addpath(('D:\vlfeat-0.9.14\toolbox'));
% vl_setup
addpath(('./rstEval'));
% addpath(['./trackers/VIVID_Tracker'])
seqs=configSeqs;
trackers=configTrackers;
shiftTypeSet = {'left','right','up','down','topLeft','topRight','bottomLeft','bottomRight','scale_8','scale_9','scale_11','scale_12'};
evalType='TRE'; %'OPE','SRE','TRE'
diary(['/tmp/' evalType '.txt']);
numSeq=length(seqs);
numTrk=length(trackers);
finalPath = ['./results/results_' evalType '_CVPR13/'];
if ~exist(finalPath,'dir')
mkdir(finalPath);
end
tmpRes_path = ['/tmp/' evalType '/'];
bSaveImage=0;
if ~exist(tmpRes_path,'dir')
mkdir(tmpRes_path);
end
pathAnno = './anno/';
for idxSeq=1:length(seqs)
s = seqs{idxSeq};
% if ~strcmp(s.name, 'coke')
% continue;
% end
s.len = s.endFrame - s.startFrame + 1;
s.s_frames = cell(s.len,1);
nz = strcat('%0',num2str(s.nz),'d'); %number of zeros in the name of image
for i=1:s.len
image_no = s.startFrame + (i-1);
id = sprintf(nz,image_no);
s.s_frames{i} = strcat(s.path,id,'.',s.ext);
end
img = imread(s.s_frames{1});
[imgH,imgW,ch]=size(img);
rect_anno = dlmread([pathAnno s.name '.txt']);
numSeg = 20;
[subSeqs, subAnno]=splitSeqTRE(s,numSeg,rect_anno);
switch evalType
case 'SRE'
subS = subSeqs{1};
subA = subAnno{1};
subSeqs=[];
subAnno=[];
r=subS.init_rect;
for i=1:length(shiftTypeSet)
subSeqs{i} = subS;
shiftType = shiftTypeSet{i};
subSeqs{i}.init_rect=shiftInitBB(subS.init_rect,shiftType,imgH,imgW);
subSeqs{i}.shiftType = shiftType;
subAnno{i} = subA;
end
case 'OPE'
subS = subSeqs{1};
subSeqs=[];
subSeqs{1} = subS;
subA = subAnno{1};
subAnno=[];
subAnno{1} = subA;
otherwise
end
for idxTrk=1:numTrk
t = trackers{idxTrk};
% if ~strcmp(t.name, 'LSK')
% continue;
% end
% validate the results
if exist([finalPath s.name '_' t.name '.mat'])
load([finalPath s.name '_' t.name '.mat']);
bfail=checkResult(results, subAnno);
if bfail
disp([s.name ' ' t.name]);
end
continue;
end
switch t.name
case {'VTD','VTS'}
continue;
end
results = [];
for idx=1:length(subSeqs)
disp([num2str(idxTrk) '_' t.name ', ' num2str(idxSeq) '_' s.name ': ' num2str(idx) '/' num2str(length(subSeqs))])
rp = [tmpRes_path s.name '_' t.name '_' num2str(idx) '/'];
if bSaveImage&~exist(rp,'dir')
mkdir(rp);
end
subS = subSeqs{idx};
subS.name = [subS.name '_' num2str(idx)];
% subS.s_frames = subS.s_frames(1:20);
% subS.len=20;
% subS.endFrame=subS.startFrame+subS.len-1;
funcName = ['res=run_' t.name '(subS, rp, bSaveImage);'];
try
switch t.name
case {'VR','TM','RS','PD','MS'}
otherwise
cd(['./trackers/' t.name]);
addpath(genpath('./'))
end
eval(funcName);
switch t.name
case {'VR','TM','RS','PD','MS'}
otherwise
rmpath(genpath('./'))
cd('../../');
end
if isempty(res)
results = [];
break;
end
catch err
disp('error');
rmpath(genpath('./'))
cd('../../');
res=[];
continue;
end
res.len = subS.len;
res.annoBegin = subS.annoBegin;
res.startFrame = subS.startFrame;
switch evalType
case 'SRE'
res.shiftType = shiftTypeSet{idx};
end
results{idx} = res;
end
save([finalPath s.name '_' t.name '.mat'], 'results');
end
end
figure
t=clock;
t=uint8(t(2:end));
disp([num2str(t(1)) '/' num2str(t(2)) ' ' num2str(t(3)) ':' num2str(t(4)) ':' num2str(t(5))]);