資源簡(jiǎn)介
時(shí)空上下文視覺(jué)跟蹤(STC)算法的代碼,包含原作者的matlab代碼和zouxy09博主實(shí)現(xiàn)的多尺度時(shí)空上下文視覺(jué)追蹤C(jī)++代碼,其中C++代碼已經(jīng)解決了邊界處理問(wèn)題。

代碼片段和文件信息
#include?“STCTracker.h“
#include?
#include?
#include?
#include?
#include?
//?Global?variables
Rect?box;
bool?drawing_box?=?false;
bool?gotBB?=?false;
//?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?main(int?argc?char?*?argv[])
{
VideoCapture?capture;
capture.open(“C:\\Users\\Administrator\\Desktop\\David.avi“);
bool?fromfile?=?true;
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?);?
Mat?framefirstgrayImg;
capture?>>?frame;
frame.copyTo(first);
while(!gotBB)
{
first.copyTo(frame);
rectangle(frameboxScalar(25500)2);?
imshow(“Tracker“?frame);
if?(cvWaitKey(20)?==?27)
return?1;
}
//Remove?callback
cvSetMouseCallback(“Tracker“?NULL?NULL?);?
printf(“Initial=?x:%d?y:%d?h:%d?w:%d\n“box.xbox.ybox.heightbox.width);
cvtColor(frame?grayImg?CV_RGB2GRAY);???
STCTracker?stcTracker;
stcTracker.init(grayImg?box);
int?frameCount?=?0;
while?(capture.read(frame))
{
if?(frame.empty())
return?-1;
double?t?=?(double)cvGetTickCount();
frameCount++;
cvtColor(frame?grayImg?CV_RGB2GRAY);
stcTracker.tracking(grayImg?box?frameCount);
//?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;
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2016-09-20?20:58??STC(matlab和C++)\
?????目錄???????????0??2016-09-20?20:58??STC(matlab和C++)\C++\
?????文件????????2347??2015-06-05?20:33??STC(matlab和C++)\C++\runTracker.cpp
?????文件????????8300??2015-06-05?20:32??STC(matlab和C++)\C++\STCTracker.cpp
?????文件????????1585??2015-06-05?14:37??STC(matlab和C++)\C++\STCTracker.h
?????目錄???????????0??2016-09-20?20:58??STC(matlab和C++)\Matlab\
?????目錄???????????0??2016-09-20?21:02??STC(matlab和C++)\Matlab\data\
?????文件????????4048??2016-09-20?17:29??STC(matlab和C++)\Matlab\demoSTC.m
?????文件?????????617??2013-11-03?15:01??STC(matlab和C++)\Matlab\get_context.m
?????文件??????????24??2013-10-27?12:07??STC(matlab和C++)\Matlab\readme.txt
評(píng)論
共有 條評(píng)論