OpenCV的视频捕获和FPS的问题 [英] OpenCV Video capture and fps problem

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

问题描述

我是从MacOSX上使用我的OpenCV的摄像头录制视频。它工作正常,但是当我尝试在QuickTime中播放我捕获的视频在播放速度太快。即,我从摄像头中捕获了10秒,但是当我的QuickTime播放视频是2秒。

I'm capturing video from my webcam using OpenCV on MacOSX. It works fine but when I try to play on QuickTime my captured video it plays too fast. i.e. I capture from camera for 10 seconds but when I play on QuickTime the video is 2 seconds.

我试图改变从每秒25帧到10和它的作品相当不错,但我敢肯定,这不是正确的方法:

I've tried to change fps from 25 to 10 and It's works quite fine, but I'm sure it's not the correct process:

CvVideoWriter *writer = 0;  
int isColor = 1;
int fps     = 25;
int frameW  = 640; // 744 for firewire cameras
int frameH  = 480; // 480 for firewire cameras

问题是,现在我已经用摄像头捕捉到,但计划的真正pourpose是从连接到我的Mac任何外部来源拍照。

The problem is that for now I've to capture with WebCam but the real pourpose of program is to capture image from any external source connected to my Mac.

我使用这个code捕捉:

I'm using this code to capture:

for (;;) {
  cvGrabFrame(capture)
  image = cvRetrieveFrame(capture);
  cvWriteFrame( writer, image );
}

任何暗示?我也显示出对cvNamedWindow摄像头输出,我怎么可以在这个窗口提高质量?

Any hint? I'm also showing webcam output on cvNamedWindow, how can I improve quality in this windows?

非常感谢大家!

安德烈!

推荐答案

我有你所说的(约10fps的),并发现了类似性能的连续 retrieveFrame()通话已经永远服用。我发现, getCaptureProperty(CV_CAP_PROP_FPS)是在默认值为0。我用这个变化值25 setCaptureProperty(CV_CAP_PROP_FPS,25.0)键,能够捕捉更快。

I was having similar performance as you mentioned (about 10fps) and found that successive retrieveFrame() calls were taking forever. I found that getCaptureProperty(CV_CAP_PROP_FPS) was at a default value of 0. I changed this value to 25 using setCaptureProperty(CV_CAP_PROP_FPS,25.0) and was able to capture much faster.

这篇关于OpenCV的视频捕获和FPS的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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