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