如何跑通TLD算法

      看到好友都有写博客的习惯,对我这么一个表达不清的人来说,真是赶鸭子上架啊,自己也试着写写吧,不好之处还望海涵。

      下面我把在学习TLD算法中的遇到一些问题及解决方法列出来,希望对初学者有点帮助。

     先说一下,我电脑的程序配置吧:XP+VS2010+MATLAB2012b+OpenCV2.4.3

     跑此程序,首先应该运行compile.m程序,然后再运行run_TLD.m,在任何机器上,首先得保证matlab的mex命令设置正确,其可通过

mex -setup命令实现,然后打开compile.m文件,将源代码中:

include = ' -Ic:\OpenCV2.2\include\opencv\ -Ic:\OpenCV2.2\include\';
libpath = 'c:\OpenCV2.2\lib\';
改为自己电脑中的路径,如我的就是:

include = ' -ID:\OpenCV\opencv\build\include\-ID:\OpenCV\opencv\build\include\opencv\-ID:\OpenCV\opencv\build\include\opencv2\';

    libpath = 'D:\OpenCV\opencv\build\x86\vc10\lib\';


这样改好了,一般就是能够正常编译运行了,然而,若用VS2010则又有不同,根据作者的说法https://github.com/zk00006/OpenTLD/wiki/Installation

You will need some extension toolboxes for Matlab, seebelow.

 

1) Install OpenCV2.2: compile OpenCV, set system PATHvariable to link to OpenCV DLLs

 

2) Setup mex compiler in Matlab: run: mex -setup,select Visual Studio 2010 compiler from the list

 

3) Compilation of mex files: check paths in'compile.m' file, run 'compile.m'

 

3.1) If you are using Matlab 2011a, in TLD source, comment out the following linesin lk.cpp, fern.cpp, and bb_overlap.cpp (Otherwise, you will get an error aboutint being undefined which is a no-no in 2010):

#ifdef _CHAR16_T

#define CHAR16_T

#endif

4) run 'run_TLD.m', TLD should track a motorbike

 作者的意思很简单,就是需要把

lk.cpp, fern.cpp, and bb_overlap.cpp

这几个文件中的这几行代码

#ifdef _CHAR16_T

#define CHAR16_T

#endif

注释掉

然后重新运行compile.m文件,最后运行'run_TLD.m

按照以上方法做了,我的能成功编译了,但在run_TLD.m的时候还是出现了一些莫名奇妙的错误

首先,可能会出现如下问题:

Cannot find anexact (case-sensitive) match for 'FSPECIAL'

 

The closest matchis: fspecial

inE:\Matlab800\instalfile\toolbox\images\images\fspecial.m

 

 

Error in img_blur(line 29)

h =FSPECIAL('gaussian',csize,sigma);

解决方法是把img_blur文件中h =FSPECIAL('gaussian',csize,sigma);

的FSPECIAL换成全小写的。

然后重新编译compile文件,运行run_TLD,此时会出现如下类似问题:

??? UnexpectedStandard exception from MEX file.

What()is:/Users/liam/projects/OpenCV-2.3.1/modules/core/src/matrix.cpp:1305:

error: (-27)create() called for the missing output array in function create

 

Error in ==>tldTracking at 30

xFJ =lk(2,tld.img{I}.input,tld.img{J}.input,xFI,xFI); % track all points by

Lucas-Kanadetracker from frame I to frame J, estimate Forward-Backward error,

and NCC for eachpoint

 

Error in ==>tldProcessFrame at 25

[tBB tConf tValidtld] = tldTracking(tld,tld.bb(:,I-1),I-1,I); % frame-to-frame

tracking(MedianFlow)

 

Error in ==>tldExample at 41

tld =tldProcessFrame(tld,i); % process frame i

 

Error in ==>run_TLD at 43

[bb,conf] =tldExample(opt);

解决方法是对于lk.cpp文件中的186行,这里看仔细了,是这一行:

cvCalcOpticalFlowPyrLK(IMG[J], IMG[I], PYR[J], PYR[I], points[1], points[2], nPts,cvSize(win_size,win_size), Level,0     , 0,cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03),CV_LKFLOW_INITIAL_GUESSES | CV_LKFLOW_PYR_A_READY | CV_LKFLOW_PYR_B_READY );

改成如下:

cvCalcOpticalFlowPyrLK(IMG[J], IMG[I], PYR[J], PYR[I], points[1], points[2], nPts,cvSize(win_size,win_size), Level,status     , 0,cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03),CV_LKFLOW_INITIAL_GUESSES | CV_LKFLOW_PYR_A_READY | CV_LKFLOW_PYR_B_READY );

这样修改之后,注意,需要重新运行compile.m,然后运行run_TLD.m即可。


对于c++版本的,我就不用多说了吧,只需把vs工程中的opencv设置好就没有问题了


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值