使用OpenCV设置QuickCam Pro 3000的框架大小? [英] Setting frame size of QuickCam Pro 3000 with OpenCV?

查看:135
本文介绍了使用OpenCV设置QuickCam Pro 3000的框架大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OpenCV 2.4.6使用我的旧Logitech QuickCam Pro 3000网络摄像头抓取图像。使用 VideoCapture :: set(CV_CAP_PROP_FRAME_WIDTH,...)我无法设置宽度的值(idem为高度)。 set(...)总是返回 false

I'm using OpenCV 2.4.6 to grab images with my old Logitech QuickCam Pro 3000 webcam. Using VideoCapture::set( CV_CAP_PROP_FRAME_WIDTH, ... ) I'm not able to set the value of the width (idem for the height). set(...) always returns false.

是否正常?

PS 我在Linux上( kubuntu ),似乎使用V4L。

P.S. I'm on Linux (kubuntu) and it seems to use V4L.

推荐答案

您的相机似乎未正确初始化。以下代码适用于我。

It seems that your camera was not initialized properly. The following code works for me.

using namespace cv;

[...]

VideoCapture capture(0);
capture.set(CV_CAP_PROP_FRAME_WIDTH, width);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, height);

我尝试了一下,发现了以下问题:

I experimented with it a bit and found the following issues:


  1. 如果 capture 未初始化,则capture.set 返回0。

  2. capture.set 如果相机正忙,则返回0(使用它的另一个进程)。

  1. capture.set returns 0 if capture was not initialized.
  2. capture.set returns 0 if camera is busy (another process using it).


    不能保证调用 VideoCapture :: set 会将相机分辨率更改为所需的分辨率。例如,使用我的Logitech HD Pro网络摄像头C290,将分辨率设置为640x480和1920x1080即可。但是当我尝试1024x768, VideoCapture :: set 返回true,但实际分辨率设置为960x720。所以,阅读一个框架后检查实际分辨率。

It is not guaranteed that calling VideoCapture::set will change camera resolution to your desired resolution. For example, with my Logitech HD Pro Webcam C290, setting resolution to 640x480 and 1920x1080 works. But when I try 1024x768, VideoCapture::set returns true, but actual resolution is set to 960x720. So, check the actual resolution after reading a frame.

这篇关于使用OpenCV设置QuickCam Pro 3000的框架大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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