main_running.m
addpath('./util');%添加util路径
addpath(('D:\Document\20190415-0422\vlfeat-0.9.20-bin\vlfeat-0.9.20\toolbox'));%添加vlfeat工具路径
vl_setup%安装vlfeat
addpath(('./rstEval'));%添加rstEval路径
addpath(['./trackers/VIVID_Tracker'])
seqs=configSeqs;%读取测试集序列文件,configSeqs中保存图片位置等信息
trackers=configTrackers;%读取跟踪器信息,包括跟踪器程序入口
shiftTypeSet = {'left','right','up','down','topLeft','topRight','bottomLeft','bottomRight','scale_8','scale_9','scale_11','scale_12'};%变换类型
evalType='OPE'; %'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};%保存第i个视频信息
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);%当前帧索引i
id = sprintf(nz,image_no);
s.s_frames{i} = strcat(s.path,id,'.',s.ext);%第i帧图片路径
end
img = imread(s.s_frames{1});%读取第1帧图片
[imgH,imgW,ch]=size(img);%图片宽高
rect_anno = dlmread([pathAnno s.name '.txt']);%当前视频序列的注释文件
numSeg = 20;
[subSeqs, subAnno]=splitSeqTRE(s,numSeg,rect_anno);%考虑时间鲁棒性,将图片序列分成20个片段
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};%第t个跟踪器索引
% 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))])%第idxTrk个跟踪器在第idxSeq个序列上第idx个片段的跟踪
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)];
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