資源簡介
用KCF的追蹤過程代替TLD的追蹤過程,保留了TLD的檢測和學習過程,但是沒有加入旋轉的特征學習,對于旋轉的處理還是不行,有空自己慢慢寫咯,要是tld的代碼都運行不來的話建議先看看如何加載tld的配置文件,要是opencv的配置也不會的話,建議不要下載
代碼片段和文件信息
#include???
#include???
#include???
#include???//c++中的sstream類,提供了程序和string對象之間的I/O,可以通過ostringstream??
????????????????????//和instringstream兩個類來聲明對象,分別對應輸出流和輸入流??
#include???
#include???
#include?“kcftracker.hpp“
using?namespace?cv;??
using?namespace?std;??
bool?HOG?=?true;
bool?FIXEDWINDOW?=?false;
bool?MULTISCALE?=?true;
bool?SILENT?=?false;
bool?LAB?=?false;
int?key;
//?Create?KCFTracker?object
KCFTracker?tracker(HOG?FIXEDWINDOW?MULTISCALE?LAB);
//?Tracker?results
Rect?result;
/////////////////////////////////////////////////////////////////
//Global?variables??
Rect?box;??
bool?drawing_box?=?false;??
bool?gotBB?=?false;??
bool?tl?=?true;??
bool?rep?=?false;??
bool?fromfile=false;??
string?video;??
??
//讀取記錄bounding?box的文件,獲得bounding?box的四個參數:左上角坐標x,y和寬高??
/*如在\datasets\06_car\init.txt中:記錄了初始目標的bounding?box,內容如下?
142125232164????
*/??
void?readBB(char*?file){??
??ifstream?bb_file?(file);??//以輸入方式打開文件??
??string?line;??
??//istream&?getline?(?istream&??string&?);??
??//將輸入流is中讀到的字符存入str中,終結符默認為?‘\n‘(換行符)???
??getline(bb_file?line);??
??istringstream?linestream(line);?//istringstream對象可以綁定一行字符串,然后以空格為分隔符把該行分隔開來。??
??string?x1y1x2y2;??
????
??//istream&?getline?(?istream?&is??string?&str??char?delim?);???
??//將輸入流is中讀到的字符存入str中,直到遇到終結符delim才結束。??
??getline?(linestreamx1?‘‘);??
??getline?(linestreamy1?‘‘);??
??getline?(linestreamx2?‘‘);??
??getline?(linestreamy2?‘‘);??
????
??//atoi?功?能:?把字符串轉換成整型數??
??int?x?=?atoi(x1.c_str());//?=?(int)file[“bb_x“];??
??int?y?=?atoi(y1.c_str());//?=?(int)file[“bb_y“];??
??int?w?=?atoi(x2.c_str())-x;//?=?(int)file[“bb_w“];??
??int?h?=?atoi(y2.c_str())-y;//?=?(int)file[“bb_h“];??
??box?=?Rect(xywh);??
}??
??
//bounding?box?mouse?callback??
//鼠標的響應就是得到目標區域的范圍,用鼠標選中bounding?box。??
void?mouseHandler(int?event?int?x?int?y?int?flags?void?*param){??
??switch(?event?){??
??case?CV_EVENT_MOUSEMOVE:??
????if?(drawing_box){??
????????box.width?=?x-box.x;??
????????box.height?=?y-box.y;??
????}??
????break;??
??case?CV_EVENT_LBUTTONDOWN:??
????drawing_box?=?true;??
????box?=?Rect(?x?y?0?0?);??
????break;??
??case?CV_EVENT_LBUTTONUP:??
????drawing_box?=?false;??
????if(?box.width?0?){??
????????box.x?+=?box.width;??
????????box.width?*=?-1;??
????}??
????if(?box.height?0?){??
????????box.y?+=?box.height;??
????????box.height?*=?-1;??
????}??
????gotBB?=?true;???//已經獲得bounding?box??
????break;??
??}??
}??
??
void?print_help(char**?argv){??
??printf(“use:\n?????%s?-p?/path/parameters.yml\n“argv[0]);??
??printf(“-s????source?video\n-b????????bounding?box?file\n-tl??track?and?learn\n-r?????repeat\n“);??
}??
??
//分析運行程序時的命令行參數??
void?read_options(int?argc?char**?argv?VideoCapture&?capture?FileStorage?&fs){??
??for?(int?i=0;i ??????if?(strcmp(argv[i]“-b“)==0){??
??????????if?(argc>i){??
??????????????readBB(argv[i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-03-03?16:27??TLD_test1\
?????目錄???????????0??2018-03-03?16:25??TLD_test1\ConsoleApplication2\
?????文件????????1003??2016-03-31?20:56??TLD_test1\ConsoleApplication2.sln
?????文件???????57856??2018-03-03?16:24??TLD_test1\ConsoleApplication2.v12.suo
?????文件???????????0??2018-03-03?16:22??TLD_test1\ConsoleApplication2\bounding_boxes.txt
?????文件????????6426??2017-04-21?11:18??TLD_test1\ConsoleApplication2\ConsoleApplication2.vcxproj
?????文件????????2555??2017-04-21?11:18??TLD_test1\ConsoleApplication2\ConsoleApplication2.vcxproj.filters
?????文件?????????758??2017-04-06?01:20??TLD_test1\ConsoleApplication2\ConsoleApplication2.vcxproj.user
?????文件?????????105??2017-04-20?21:31??TLD_test1\ConsoleApplication2\mydefine.h
?????文件????????9237??2018-03-03?16:24??TLD_test1\ConsoleApplication2\open.cpp
?????文件?????????524??2011-12-04?21:39??TLD_test1\ConsoleApplication2\parameters.yml
?????目錄???????????0??2018-03-03?16:27??TLD_test1\ConsoleApplication2\Release\
?????目錄???????????0??2018-03-03?16:25??TLD_test1\Debug\
?????目錄???????????0??2018-03-03?16:24??TLD_test1\KCFdemo\
?????目錄???????????0??2018-03-03?16:26??TLD_test1\KCFdemo\Debug\
?????文件????????7031??2017-03-22?19:16??TLD_test1\KCFdemo\ffttools.hpp
?????文件???????18390??2017-03-22?19:16??TLD_test1\KCFdemo\fhog.cpp
?????文件????????5605??2015-12-01?12:10??TLD_test1\KCFdemo\fhog.hpp
?????文件????????5761??2016-12-13?23:32??TLD_test1\KCFdemo\KCFdemo.vcxproj
?????文件????????1886??2016-11-07?09:52??TLD_test1\KCFdemo\KCFdemo.vcxproj.filters
?????文件?????????165??2016-12-13?17:05??TLD_test1\KCFdemo\KCFdemo.vcxproj.user
?????文件???????21481??2017-04-21?20:17??TLD_test1\KCFdemo\kcftracker.cpp
?????文件????????8571??2017-04-21?20:17??TLD_test1\KCFdemo\kcftracker.hpp
?????文件?????????617??2016-11-07?10:59??TLD_test1\KCFdemo\labdata.hpp
?????文件????????4578??2017-03-22?19:16??TLD_test1\KCFdemo\recttools.hpp
?????目錄???????????0??2018-03-03?16:26??TLD_test1\KCFdemo\Release\
?????文件????????2475??2016-12-13?23:35??TLD_test1\KCFdemo\runtracker.cpp
?????文件?????????216??2016-11-03?14:05??TLD_test1\KCFdemo\stdafx.cpp
?????文件?????????234??2016-11-03?14:05??TLD_test1\KCFdemo\stdafx.h
?????文件?????????236??2016-11-03?14:05??TLD_test1\KCFdemo\targetver.h
?????文件????????1365??2017-04-21?20:17??TLD_test1\KCFdemo\tracker.h
............此處省略145個文件信息
- 上一篇:CMW500終端測試
- 下一篇:90sec版本火狐瀏覽器firefox
評論
共有 條評論