该函数处理tld中的每一帧。
用到的函数:tldtrcaking
function tld = tldProcessFrame(tld,i)
I = tld.source.idx(i); % get current index
获取当前的索引咯
tld.img{I} = img_get(tld.source,I); % grab frame from camera / load image
读取数据
% TRACKER ----------------------------------------------------------------
[tBB tConf tValid tld] = tldTracking(tld,tld.bb(:,I-1),I-1,I); % frame-to-frame tracking (MedianFlow)
第一个函数:tldtrcaking 中值光流法 获得的输出有:tBB-》可能是tracking获得的目标框,tConf->这种方法的相似度,tValid-》这种方法的有效性,tld->临时变量,值得深究。
输入很奇怪,两次tld 未搞清他们都是什么
% DETECTOR ----------------------------------------------------------------
[dBB dConf tld] = tldDetection(tld,I); % detect appearances by cascaded detector (variance filter -> ensemble classifier -> nearest neightbour)
第二个函数:检测器tldDetection 三个过滤器
获得的输出: dBB dConf tld 类同于tracking
% INTEGRATOR --------------------------------------------------------------
DT = 1; if isempty(dBB), DT = 0; end % is detector defined?
TR = 1; if isempty(tBB), TR = 0; end % is tracker defined?
DT-》detector 是否存在
TR-》tracking是否存在 1为存在。
if TR % if tracker is defined
% copy tracker‘s result
tld.bb(:,I) = tBB;
tld.conf(I) = tConf;
tld.size(I) = 1;
tld.valid(I) = tValid;
if DT % if detections are also defined//这里考虑的是tracking和detector都存在的情况
[cBB,cConf,cSize] = bb_cluster_confidence(dBB,dConf); % cluster detections
id = bb_overlap(tld.bb(:,I),cBB) < 0.5 & cConf > tld.conf(I); % get indexes of all clusters that are far from tracker and are more confident then the tracker
if sum(id) == 1 % if there is ONE such a cluster, re-initialize the tracker
tld.bb(:,I) = cBB(:,id);
tld.conf(I) = cConf(:,id);
tld.size(I) = cSize(:,id);
tld.valid(I) = 0;
else % othervide adjust the tracker‘s trajectory
idTr = bb_overlap(tBB,tld.dt{I}.bb) > 0.7; % get indexes of close detections
tld.bb(:,I) = mean([repmat(tBB,1,10) tld.dt{I}.bb(:,idTr)],2); % weighted average trackers trajectory with the close detections
end
end
else % if tracker is not defined
if DT % and detector is defined
[cBB,cConf,cSize] = bb_cluster_confidence(dBB,dConf); % cluster detections
if length(cConf) == 1 % and if there is just a single cluster, re-initalize the tracker
tld.bb(:,I) = cBB;
tld.conf(I) = cConf;
tld.size(I) = cSize;
tld.valid(I) = 0;
end
end
end
% LEARNING ----------------------------------------------------------------
if tld.control.update_detector && tld.valid(I) == 1
tld = tldLearning(tld,I);
end
% display drawing: get center of bounding box and save it to a drawn line
if ~isnan(tld.bb(1,I))
tld.draw(:,end+1) = bb_center(tld.bb(:,I));
if tld.plot.draw == 0, tld.draw(:,end) = nan; end
else
tld.draw = zeros(2,0);
end
if tld.control.drop_img && I > 2, tld.img{I-1} = {}; end % forget previous image