OpenCV 寻道功能/倒带
我一直在尝试使用 C++ 中的 OpenCV 查找/实现搜索和倒带功能(用于视频(.avi)),但除了一次浏览整个文件并保存每个图像之外,我找不到其他方法。还有其他办法吗?
任何帮助将不胜感激;提前致谢!
I've been trying to find/implement a seek and rewind function (for video (.avi)) using OpenCV in C++, but I cant find a way of doing it, other than going through the entire file once and saving each image. Is there any other way?
Any help would be much appreciated; Thanks ahead of time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 cvSetCaptureProperty(),您可以循环帧,可以以毫秒为单位,也可以按顺序帧编号。
property_id 是您需要使用的属性。它可以是以下之一:
前两个是您感兴趣的。
编辑:更多信息:)
您只需使用各种帧索引重复调用上述函数即可循环浏览帧。
示例:
您可以放置类似的代码,以便在每次用户单击按钮前进/后退视频时执行。
C++ 方法(OpenCV 2 及更高版本)将使用此方法来代替相同的 property_id 和值。
Using cvSetCaptureProperty() you can cycle through frames, either in miliseconds or by ordinal frame number.
property_id is a property you would need to use. It can be one of the following:
The first two is of your interest.
EDIT: more info :)
You can cycle through frames just by repeatedly calling the mentioned function with various frame indices.
Example:
You could put similar code to execute each time user clicks a button to forward/rewind the video.
The C++ method (OpenCV 2 and higher) would be to use this method instead with the same property_id and value.
我认为您必须将整个文件读入 IplImages 数组,然后进行处理。原因是,cvQueryFrame 是一个单向过程,它按顺序一次读取一帧。我想不出其他办法了。根据视频的长度,初始化时间可能不会太差。
cvTrackbars 正如你所说,主要用于更改参数。它们更改变量的值(以指针形式作为参数给出)并抛出回调函数。不幸的是,据我所知,它们是 HighGUI 中唯一的按钮样式元素
I think you'd have to read in the entire file into an array of IplImages, then work through that. The reason is, cvQueryFrame is a one-way process, it reads one frame at a time in order. I can't think of any other way. Depending on the length of the video the initialisation time may not be too bad.
The cvTrackbars are as you say, mainly used for altering parameters. They alter the value of a variable (given as a parameter in pointer form) and throw a callback function. Unfortunately they are the only button-style elements in HighGUI as far as I know
对于C++和opencv3.4,frame_index是你想要寻找的位置。
for C++ and opencv3.4,frame_index is the position you want to seek to.
在 highgui 库中,您将找到搜索栏的函数(cvCreateTrackbar 和朋友) 。
In the highgui library you'll find functions for a seek bar (cvCreateTrackbar and friends).