std::string video = argv[1];
VideoCapture cap(video);
在官方给出的单目标跟踪示例中,我运行之后只能出来最开始的帮助里的提示,没有跟踪的视频显示,这段代码到底是怎么提取视频的呢?
附上源码:
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
int main( int argc, char** argv ){
// show help
if(argc
cout
" Usage: tracker \n"
" examples:\n"
" example_tracking_kcf Bolt/img/%04d.jpg\n"
" example_tracking_kcf faceocc2.webm\n"
<< endl;
return 0;
}
// declares all required variables
Rect2d roi;
Mat frame;
// create a tracker object KCF MIL TLD
Ptr tracker = TrackerKCF::create();
// set input video
std::string video = argv[1];
VideoCapture cap(video);
// get bounding box
cap >> frame;
int sale = 2;
resize(frame,frame,frame.size()/2);
roi=selectROI("tracker",frame);
//quit if ROI was not selected
if(roi.width==0 || roi.height==0)
return 0;
// initialize the tracker
tracker->init(frame,roi);
// perform the tracking process
printf("Start the tracking process, press ESC to quit.\n");
for ( ;; ){
// get frame from the video
cap >> frame;
// stop the program if no more images
if(frame.rows==0 || frame.cols==0)
break;
resize(frame,frame,frame.size()/2);
// update the tracking result
tracker->update(frame,roi);
// draw the tracked object
rectangle( frame, roi, Scalar( 255, 0, 0 ), 2, 1 );
// show image with the tracked object
imshow("tracker",frame);
//quit on ESC button
if(waitKey(1)==27)break;
}
return 0;
}
基于KCF算法的opencv3目标跟踪
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答
悬赏问题
- ¥15 chaquopy python 安卓
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 有没有帮写代码做实验仿真的
- ¥15 報錯:Person is not mapped,如何解決?
- ¥30 vmware exsi重置后登不上
- ¥15 易盾点选的cb参数怎么解啊
- ¥15 MATLAB运行显示错误,如何解决?
- ¥15 c++头文件不能识别CDialog
- ¥15 Excel发现不可读取的内容
- ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题