資源簡介
c++版stc跟蹤代碼,已在vs2008+opencv2.3.1上調試。
代碼片段和文件信息
//?Run_STC.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?“stc.h“
#include?
#include?
#include?
#include?
using?namespace?cv;
using?namespace?std;
Rect?box;
bool?drawing_box=false;
bool?getbox=false;
const?char?winname[]=“STC?Tracking“;
void?drawbox(Mat?imageRect?box)
{
rectangle(imagePoint(box.x?box.y)?Point(box.x+box.widthbox.y+box.height)Scalar(25500)1);
}
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;
}
getbox=true;
break;
}
}
int?main()
{
VideoCapture?capture;
capture.open(“david.mpg“);
if?(!capture.isOpened())
{
cout<<“God!!**Video?cannot?open!“< return?-1;
}
namedWindow(winnameCV_WINDOW_AUTOSIZE);
setMouseCallback(winnamemouseHandlerNULL);
Mat?frame;
Mat?gray;
capture>>frame;
while(!getbox)
{
capture>>frame;
drawbox(framebox);
imshow(winnameframe);
if?(waitKey(33)==‘q‘)
return?0;
}
setMouseCallback(winnameNULLNULL);
STC?stc;
cvtColor(framegrayCV_BGR2GRAY);
stc.init(graybox);
int?frame_Num=1;
while?(capture.read(frame))
{
cvtColor(framegrayCV_BGR2GRAY);
???stc.processframe(grayboxframe_Num);
drawbox(framebox);
frame_Num++;
imshow(winnameframe);
char?c;
c=waitKey(33);????//先延時33ms
if?(c==27)????????//按ESC鍵退出
break;
}
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-09-09?09:12??Run_STC\
?????文件???????12292??2014-09-09?09:13??Run_STC\.DS_Store
?????目錄???????????0??2014-09-09?09:20??__MACOSX\
?????目錄???????????0??2014-09-09?09:20??__MACOSX\Run_STC\
?????文件?????????120??2014-09-09?09:13??__MACOSX\Run_STC\._.DS_Store
?????目錄???????????0??2014-09-09?09:14??Run_STC\Debug\
?????文件??????101376??2014-09-06?19:45??Run_STC\Debug\Run_STC.exe
?????文件??????610884??2014-09-06?19:45??Run_STC\Debug\Run_STC.ilk
?????文件?????1428480??2014-09-06?19:45??Run_STC\Debug\Run_STC.pdb
?????目錄???????????0??2014-09-09?09:14??Run_STC\Release\
?????文件???????31232??2014-09-06?19:45??Run_STC\Release\Run_STC.exe
?????文件??????887808??2014-09-06?19:45??Run_STC\Release\Run_STC.pdb
?????目錄???????????0??2014-09-09?09:12??Run_STC\Run_STC\
?????文件????????6148??2014-09-09?09:12??Run_STC\Run_STC\.DS_Store
?????目錄???????????0??2014-09-09?09:20??__MACOSX\Run_STC\Run_STC\
?????文件?????????120??2014-09-09?09:12??__MACOSX\Run_STC\Run_STC\._.DS_Store
?????目錄???????????0??2014-09-09?09:14??Run_STC\Run_STC\data\
?????文件??????102935??2011-04-17?06:11??Run_STC\Run_STC\data\00001.png
?????文件??????101601??2011-04-17?06:11??Run_STC\Run_STC\data\00002.png
?????文件???????97101??2011-04-17?06:11??Run_STC\Run_STC\data\00003.png
?????文件???????99838??2011-04-17?06:11??Run_STC\Run_STC\data\00004.png
?????文件??????100068??2011-04-17?06:11??Run_STC\Run_STC\data\00005.png
?????文件???????99023??2011-04-17?06:11??Run_STC\Run_STC\data\00006.png
?????文件??????103474??2011-04-17?06:11??Run_STC\Run_STC\data\00007.png
?????文件??????103750??2011-04-17?06:11??Run_STC\Run_STC\data\00008.png
?????文件???????84870??2011-04-17?06:11??Run_STC\Run_STC\data\00009.png
?????文件???????88138??2011-04-17?06:11??Run_STC\Run_STC\data\00010.png
?????文件???????93755??2011-04-17?06:11??Run_STC\Run_STC\data\00011.png
?????文件???????95938??2011-04-17?06:11??Run_STC\Run_STC\data\00012.png
?????文件???????96200??2011-04-17?06:11??Run_STC\Run_STC\data\00013.png
?????文件???????98503??2011-04-17?06:11??Run_STC\Run_STC\data\00014.png
............此處省略121個文件信息
- 上一篇:基于SSH框架的在線考試系統
- 下一篇:cat021報文解析——C++語言實現
評論
共有 條評論