简体   繁体   English

在导入的视频上运行Camshift演示

[英]Running the Camshift demo on an imported video

I'm trying to use the camshift algorithm to track the path of a colour invariant circle from a prerecorded video. 我正在尝试使用camshift算法从预先录制的视频中跟踪颜色不变圆的路径。 I tried using the demo code found at https://github.com/Itseez/opencv/blob/master/samples/cpp/camshiftdemo.cpp but I'm trying to load a prerecorded video as my I keep getting an error asking me to insert a camera. 我尝试使用在https://github.com/Itseez/opencv/blob/master/samples/cpp/camshiftdemo.cpp上找到的演示代码,但由于我不断收到错误消息,我试图加载预先录制的视频插入相机。

I modified the following line 我修改了以下行

VideoCapture cap;
Mat frame;

to

VideoCapture cap("C:/Users/samplefile.mov");

and then 接着

cap.read(frame);

This method works for just importing a video but for the life of me, I can't get it to work with the demo. 这种方法仅适用于导入视频,但是对于我的生命来说,我无法使其与演示一起使用。 Am I doing it wrong? 我做错了吗?

PS Are there any other methods you could suggest to draw the bar path of a given circle in a video within a region of interest? PS:您还有其他方法可以建议在感兴趣区域内的视频中绘制给定圆的条形路径吗? My main motivation for using the camshift algorithm is the fact that a user can simply just choose an area to work with. 我使用camshift算法的主要动机是用户可以简单地选择要使用的区域。

Solved it. 解决了。 There was an extra line 有一条额外的线

cap.open(camNum)

I missed this. 我错过了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM