【TLD】改进后的TLD视频目标跟踪方法的MATLAB仿真

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)。学习模块根据跟踪模块的结果对检测模块的这两种错误进行评估,并根据评估结果生成训练样本对检测模块的目标模型进行更新,同时对跟踪模块的关键特征点进行更新,以此来避免以后出现类似的错误。

这一部分介绍 TLD 算法的学习模块,学习模块( learning )通过对视频的在线处理来提升检测器( detector )的性能。在每一帧里,我们希望评估当前的检测器,发现它产生的错误( identify its errors ),不断更新检测器以避免将来它再次犯错。 PN 学习的关键思想是检测器产生的错误结果可以被“ P 专家”和“ N 专家”发现和识别。 P 专家识别假的负样本, N 专家识别假的正样本。当然 P 专家和 N 专家本身也会犯错。然而, P 专家和 N 专家是相互独立的,它们可以相互弥补对方发生的错误。 P 专家发生的错误, N 专家纠正,反之亦然。
下面对 PN 学习进行标准数学化。
TLD 模块的详细;流程框图如下所示

 

•PN学习包含四个部分:(1)一个待学习的分类器;(2)训练样本集--一些已知类别标签的样本;(3)监督学习--一种从训练样本集中训练分类器的方法;(4)P-N experts--在学习过程中用于产生正(训练)样本和负(训练)样本的表达函数;
•PN学习最重要的部分是分类器的错误估计。关键的想法是把假的正样本和假的负样本分别独立的处理。因此,未标记的组会被现有的分类器分为两类,每一部分由一个独立的专家分析(P专家或N专家)。
•首先根据一些已有类别标记的样本,借助监督学习方法来训练,从而得到一个初始分类器。之后,通过迭代学习,利用上一次迭代得到的分类器对所有的未赋予标签的样本数据进行分类,而P-N experts则找出那些错误分类的样本,并依此来对训练样本集做出修正,使得下一次迭代训练之后得到的分类器的性能有所改善。P-experts将那些被分类器标记为负样本,但根据结构性约束条件应该为正样本的那些样本赋予“正”的标签,并添加到训练样本集中;而N-experts则将那些被分类器标记为正样本,但根据结构性约束条件应该为负样本的那些样本赋予“负”的标签,并添加到训练样本集当中;这也就意味着,P-experts增加了分类器的鲁棒性,而N-experts则增加了分类器的判别能力。

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

猜你喜欢

转载自blog.csdn.net/ccsss22/article/details/124418807
tld