OpenCV仅捕获视频文件中的一小部分帧 [英] OpenCV captures only a fraction of the frames from a video file

查看:220
本文介绍了OpenCV仅捕获视频文件中的一小部分帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCV对AVI文件进行一些处理.一切正常,除了原始视频中只有一小部分帧被捕获的事实.

I'm using OpenCV to do some processing on an AVI file. Everything is working fine, except for the fact that only a small fraction of the frames in the original video are being captured.

这是我的代码的摘录:

capture=cvCaptureFromAVI(PATH_TO_VIDEO);
int fps=(int) cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
int frames=(int) cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
qDebug("%d frames at %d fps",frames,fps);
int framesSaved=0;

while(1) {
    frame=cvQueryFrame(capture);
    if(!frame) break;

    framesSaved++;
    data = (uchar *)frame->imageData;
    //PROCESSING
    cvWriteFrame(writer,frame);
}

cvReleaseVideoWriter(&writer);
qDebug("VIDEO SAVED: %d frames",framesSaved);

输出:

1948 frames at 50 fps
VIDEO SAVED: 105 frames

知道可能是什么问题吗?

Any idea what the problem could be?

谢谢

推荐答案

已知OpenCV VideoCapture在使用CV_CAP_PROP_FRAME_COUNT

OpenCV VideoCapture is known to have serious problems to report correct number of frames with CV_CAP_PROP_FRAME_COUNT

好消息是OpenCV的人们正在努力修复它的下一个版本.

The good news is that the guys at OpenCV are working hard to fix it for the next release.

这篇关于OpenCV仅捕获视频文件中的一小部分帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆