終於在我電腦上跑通ZK大神給的TLD代碼了


  請閱讀我前一篇文章

  在環境WIN7+VS2010+MATLAB2010b+OpenCV2.3.1,我一直沒能跑起來,極度郁悶……

  今天在搜索matrix.hpp的時候,突然發現GitHub上面,居然有人碰到的問題跟我一樣,之前遇到的error如下:

 1 ??? Unexpected Standard exception from MEX file.
 2 What() is:/Users/liam/projects/OpenCV-2.3.1/modules/core/src/matrix.cpp:1305:
 3 error: (-27) create() called for the missing output array in function create
 4 
 5 Error in ==> tldTracking at 30
 6 xFJ = lk(2,tld.img{I}.input,tld.img{J}.input,xFI,xFI); % track all points by
 7 Lucas-Kanade tracker from frame I to frame J, estimate Forward-Backward error,
 8 and NCC for each point
 9 
10 Error in ==> tldProcessFrame at 25
11 [tBB tConf tValid tld] = tldTracking(tld,tld.bb(:,I-1),I-1,I); % frame-to-frame
12 tracking (MedianFlow)
13 
14 Error in ==> tldExample at 41
15 tld = tldProcessFrame(tld,i); % process frame i
16 
17 Error in ==> run_TLD at 43
18 [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 );

  將上述紅色的0改為status,如下:

 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即可,得到的結果還是有點奇怪的,在VS2005+OPENCV2.2中,是存在跟丟的情況,每秒處理的幀數有16幀左右,在VS2010+OPENCV2.3中,不存在跟丟的情況,但每秒處理的幀數為12幀左右~~

  我的源碼下載: 請重擊我

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM