VS2010+MATLAB2010b运行TLD

  TLD即Tracking Learning Detection,Zdenek Kalal大神在其主页上给出的代码http://info.ee.surrey.ac.uk/Personal/Z.Kalal/tld.html,根据网上看到的视频,ZK大神的idea和程序真是amazing,我也想拿来研究一下~
  先说一下,我电脑的程序配置吧:WIN7+VS2010+MATLAB2010b+OpenCV2.3,事实上,这个程序在我电脑上始终没有跑起来,我通过各方面找到的提示进行成功编译了,却仍然不能正常运行,后来我在其它电脑上用WIN7+VS2005+MATLAB2011a+OpenCV2.2成功的运行起来了。

  好吧,废话不多说,来看看如何进行配置吧:

  跑此程序,首先应该运行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:\OpenCV2.3\vs2010\install\include\opencv\ -ID:\OpenCV2.3\vs2010\install\include\ -ID:\OpenCV2.3\vs2010\install\include\opencv2\';
 libpath = 'D:\OpenCV2.3\vs2010\install\lib\';

当然这些只是针对windows pc改的,若换成其它系统环境,则在相应的地方更改

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

You will need some extension toolboxes for Matlab, see below.

1) Install OpenCV2.2: compile OpenCV, set system PATH variable 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 lines in lk.cpp, fern.cpp, and bb_overlap.cpp (Otherwise, you will get an error about int 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 

注释掉

  好吧,按照以上方法做了,我的能成功编译了~

  但在run_TLD.m的时候还是出现了一些莫名奇妙的错误,我正在努力debug中,实在不行,就将就着VS2005了

  调别人代码最郁闷的事,就是按照别人说的做了,却得不到预期的结果……

   唔, 后来成功了, see:
http://www.cnblogs.com/moondark/archive/2012/04/12/2444602.html

原文地址:https://www.cnblogs.com/moondark/p/2441081.html