OpenCV搜索功能/倒带

编程入门 行业动态 更新时间:2024-10-24 04:48:00
本文介绍了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!

推荐答案

使用cvSetCaptureProperty(),您可以以毫秒为单位或按顺序的帧号在帧之间循环.

Using cvSetCaptureProperty() you can cycle through frames, either in miliseconds or by ordinal frame number.

int cvSetCaptureProperty( CvCapture* capture, int property_id, double value );

property_id 是您需要使用的属性.可以是以下之一:

property_id is a property you would need to use. It can be one of the following:

  • CV_CAP_PROP_POS_MSEC -从文件开始的位置(以毫秒为单位)
  • CV_CAP_PROP_POS_FRAMES -帧中的位置
  • CV_CAP_PROP_POS_AVI_RATIO-相对单位的位置(0-文件开始,1-文件结束)
  • CV_CAP_PROP_FRAME_WIDTH-视频流中的帧宽度(仅适用于摄像机)
  • CV_CAP_PROP_FRAME_HEIGHT-视频流中帧的高度(仅适用于摄像机)
  • CV_CAP_PROP_FPS-帧速率(仅适用于相机)
  • CV_CAP_PROP_FOURCC-编解码器的4个字符的代码(仅适用于摄像机).
  • CV_CAP_PROP_POS_MSEC - position in milliseconds from the file beginning
  • CV_CAP_PROP_POS_FRAMES - position in frames
  • CV_CAP_PROP_POS_AVI_RATIO - position in relative units (0 - start of the file, 1 - end of the file)
  • CV_CAP_PROP_FRAME_WIDTH - width of frames in the video stream (only for cameras)
  • CV_CAP_PROP_FRAME_HEIGHT - height of frames in the video stream (only for cameras)
  • CV_CAP_PROP_FPS - frame rate (only for cameras)
  • CV_CAP_PROP_FOURCC - 4-character code of codec (only for cameras).
  • 前两个是您感兴趣的.

    更多信息:)

    您可以通过重复调用具有各种帧索引的上述功能来循环浏览帧.

    You can cycle through frames just by repeatedly calling the mentioned function with various frame indices.

    cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, frameIndex);

    示例:

    IplImage* frame; CvCapture* capture = cvCreateFileCapture("test.avi"); /* iterate through first 10 frames */ for (int i = 0; i < 10; i++) { /* set pointer to frame index i */ cvSetCaptureProperty(capture, CV_CAP_POS_FRAMES, i); /* capture the frame and do sth with it */ frame = cvQueryFrame(capture); }

    您可以在用户每次单击按钮以前进/后退视频时放置类似的代码来执行.

    You could put similar code to execute each time user clicks a button to forward/rewind the video.

    C ++方法(OpenCV 2和更高版本)将改用具有相同property_id和value的此方法.

    The C++ method (OpenCV 2 and higher) would be to use this method instead with the same property_id and value.

    bool VideoCapture::set(int property_id, double value)

    更多推荐

    OpenCV搜索功能/倒带

    本文发布于:2023-07-11 09:12:57,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1093540.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:搜索功能   OpenCV

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!