1.软件版本
matlab2013b
测试视频图片序列库
2.本算法理论知识
TLD是一种对视频中未知目标进行长期跟踪而设计的算法结构。它的结构如图1-1所示
•算法的结构如下:1.关于跟踪器(tracker),在假设帧与帧之间(目标物体)运动是有限的,并且目标是可见的的情况下,跟踪器(采用的是光流法)估计目标的运动状况(即接下来的位置)。但是跟踪器会在目标跑出摄像头拍摄范围时失败,并且永远不可能恢复。2.关于检测器(detector),检测器对每一帧都独立的对待,并且对每一帧图像进行扫描,找出所有过去(算法运行开始后到当前时刻)已经被观测和学习过和目标具有类似模样的所在区域(这句翻译的不好,原文:Detector treats every frame as independent and performs full scanning of the image to localize all appearances that have been observed and learned in the past.)。对于任何的检测器,都有可能发生两个类型的错误:假的正样本和假的负样本。3.关于学习模块(learning)。学习模块根据跟踪模块的结果对检测模块的这两种错误进行评估,并根据评估结果生成训练样本对检测模块的目标模型进行更新,同时对跟踪模块的“关键特征点”进行更新,以此来避免以后出现类似的错误。
3.核心代码
clc;
clear;
close all;
warning off
addpath 'New_function\Tracking\'
addpath 'New_function\detector\'
addpath 'New_function\learn\'
addpath 'tld\initial\'
addpath 'tld\'
isNew = 1 ;%0为原始TLD,1为改进TLD
isSpeed = [isNew;isNew;0];%加速,慢速,分别对三个部分,跟踪,检测,学习进行加速
CJ = 2;%设置仿真场景
addpath(genpath('.')); init_workspace;
opt.source = struct('camera',0,'input',['input',num2str(CJ),'/'],'bb0',[]); % camera/directory swith, directory_name, initial_bounding_box (if empty, it will be selected by the user)
opt.output = '_output/'; mkdir(opt.output); % output directory that will contain bounding boxes + confidence
%最小窗,要根据场景的目标大小设置过才,
if CJ == 1
min_win = 36; % minimal size of the object's bounding box in the scanning grid, it may significantly influence speed of TLD, set it to minimal size of the object
end
if CJ == 2
min_win = 9; % minimal size of the object's bounding box in the scanning grid, it may significantly influence speed of TLD, set it to minimal size of the object
end
patchsize = [15 15]; % size of normalized patch in the object detector, larger sizes increase discriminability, must be square
fliplr = 0; % if set to one, the model automatically learns mirrored versions of the object
maxbbox = 1; % fraction of evaluated bounding boxes in every frame, maxbox = 0 means detector is truned off, if you don't care about speed set it to 1
update_detector = 1; % online learning on/off, of 0 detector is trained only in the first frame and then remains fixed
opt.plot = struct('pex',0,'nex',0,'dt',0,'confidence',1,'target',0,'replace',0,'drawoutput',3,'draw',0,'pts',0,'help', 0,'patch_rescale',1,'save',0);
% Do-not-change -----------------------------------------------------------
opt.model = struct('min_win',min_win,'patchsize',patchsize,'fliplr',fliplr,'ncc_thesame',0.95,'valid',0.5,'num_trees',10,'num_features',13,'thr_fern',0.5,'thr_nn',0.65,'thr_nn_valid',0.7);
opt.p_par_init = struct('num_closest',10,'num_warps',20,'noise',5,'angle',20,'shift',0.02,'scale',0.02); % synthesis of positive examples during initialization
opt.p_par_update = struct('num_closest',10,'num_warps',10,'noise',5,'angle',10,'shift',0.02,'scale',0.02); % synthesis of positive examples during update
opt.n_par = struct('overlap',0.2,'num_patches',100); % negative examples initialization/update
opt.tracker = struct('occlusion',10);
opt.control = struct('maxbbox',maxbbox,'update_detector',update_detector,'drop_img',1,'repeat',1);
% Run TLD -----------------------------------------------------------------
%profile on;
[bb,conf] = tldExample(opt,isNew,isSpeed);
%profile off;
%profile viewer;
centerx=0.5*(bb(1,:)+ bb(3,:));
centery=0.5*(bb(2,:)+ bb(4,:));
% Save results ------------------------------------------------------------
%dlmwrite([opt.output '/tld.txt'],[centerx;centery]');
dlmwrite([opt.output '/tld.txt'],[bb]');
disp('Results saved to ./_output.');
clc;
4.操作步骤与仿真结论
5.参考文献
A10-25