資源簡介
時空上下文跟蹤算法,是最近幾年出來比較新的跟蹤,基友opencv和c++編寫,配置好后可以直接運行,跟蹤效果理想,對于跟蹤一塊理解非常好
代碼片段和文件信息
//?RunSTC.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?“STCtracker.h“??
//?Global?variables??
Rect?box;??
bool?drawing_box?=?false;??
bool?gotBB?=?false;??
char?srcvideo[]?=?“E:\\vs調試\\測試視頻\\camera1_mov.avi“;
//?bounding?box?mouse?callback??
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;??
break;??
}??
}??
int?_tmain(int?argc?_TCHAR*?argv[])
{
/*VideoCapture?capture;??
capture.open(srcvideo);??*/
bool?fromfile?=?true;??
CvCapture*?capture?=?cvCaptureFromFile(“E:\\vs調試\\測試視頻\\skating1(low?frame?rate).avi“);
/*if?(!capture.isOpened())??
{??
cout?<“capture?device?failed?to?open!“?< return?-1;??
}??*/
//Register?mouse?callback?to?draw?the?bounding?box??
cvNamedWindow(“Tracker“?CV_WINDOW_AUTOSIZE);??
cvSetMouseCallback(“Tracker“?mouseHandler?NULL?);???
/*capture?>>?frame;??*/
Mat?frame;??
frame?=?cvQueryframe(capture);
imshow(“Tracker“?frame);??
while(!gotBB)??
{??
if?(!fromfile)??
frame?=?cvQueryframe(capture);
/*capture?>>?frame;??*/
imshow(“Tracker“?frame);??
if?(cvWaitKey(20)?==?27)??
return?1;??
}??
//Remove?callback??
cvSetMouseCallback(“Tracker“?NULL?NULL?);??
box.x?=?162;
box.y?=?170;
box.width?=?35;
box.height?=?100;
STCTracker?stcTracker;??
stcTracker.init(frame?box);??
int?frameCount?=?0;??
while?(1)??
{??
/*capture?>>?frame;??*/
frame?=?cvQueryframe(capture);
if?(frame.empty())??
return?-1;??
double?t?=?(double)cvGetTickCount();??
frameCount++;??
//?tracking??
stcTracker.tracking(frame?box);??????
//?show?the?result??
stringstream?buf;??
buf?<ameCount;??
string?num?=?buf.str();??
putText(frame?num?Point(20?30)?FONT_HERSHEY_SIMPLEX?1?Scalar(0?0?255)?3);??
rectangle(frame?box?Scalar(0?0?255)?3);??
imshow(“Tracker“?frame);??
t?=?(double)cvGetTickCount()?-?t;??
cout?<“cost?time:?“?<
if?(?cvWaitKey(1)?==?27?)??
break;??
}??
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-04-12?22:27??RunSTC\
?????目錄???????????0??2016-04-11?21:30??RunSTC\Debug\
?????文件??????103936??2016-04-11?22:05??RunSTC\Debug\RunSTC.exe
?????文件??????876248??2016-04-11?22:05??RunSTC\Debug\RunSTC.ilk
?????文件?????1797120??2016-04-11?22:05??RunSTC\Debug\RunSTC.pdb
?????目錄???????????0??2016-04-12?22:10??RunSTC\ipch\
?????目錄???????????0??2016-04-12?22:10??RunSTC\ipch\runstc-7ef7deaf\
?????文件?????2359296??2016-04-12?22:10??RunSTC\ipch\runstc-7ef7deaf\runstc-fc2a456b.ipch
?????目錄???????????0??2016-04-11?21:29??RunSTC\RunSTC\
?????文件????35868672??2016-04-12?22:27??RunSTC\RunSTC.sdf
?????文件?????????885??2016-04-11?21:21??RunSTC\RunSTC.sln
?????文件???????12288??2016-04-12?22:27??RunSTC\RunSTC.suo
?????目錄???????????0??2016-04-11?22:05??RunSTC\RunSTC\Debug\
?????文件????????2712??2016-04-11?22:05??RunSTC\RunSTC\Debug\cl.command.1.tlog
?????文件???????52506??2016-04-11?22:05??RunSTC\RunSTC\Debug\CL.read.1.tlog
?????文件????????1178??2016-04-11?22:05??RunSTC\RunSTC\Debug\CL.write.1.tlog
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件???????????2??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件????????2202??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件????????4464??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件?????????734??2016-04-11?22:05??RunSTC\RunSTC\Debug\li
?????文件?????????346??2016-04-11?22:05??RunSTC\RunSTC\Debug\mt.command.1.tlog
?????文件?????????250??2016-04-11?22:05??RunSTC\RunSTC\Debug\mt.read.1.tlog
?????文件?????????250??2016-04-11?22:05??RunSTC\RunSTC\Debug\mt.write.1.tlog
?????文件?????????454??2016-04-11?21:30??RunSTC\RunSTC\Debug\rc.command.1.tlog
?????文件?????????222??2016-04-11?21:30??RunSTC\RunSTC\Debug\rc.read.1.tlog
?????文件?????????230??2016-04-11?21:30??RunSTC\RunSTC\Debug\rc.write.1.tlog
............此處省略22個文件信息
- 上一篇:effective c++中文版第三版pdf
- 下一篇:C++編寫電壓電流表儀表盤
評論
共有 條評論