3

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.

Is it normal?

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

dom_beau
  • 2,437
  • 3
  • 30
  • 59
  • possible duplicate of [Increasing camera capture resolution in OpenCV](http://stackoverflow.com/questions/14287/increasing-camera-capture-resolution-in-opencv) – karlphillip Nov 20 '13 at 04:15

1 Answers1

2

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.set returns 0 if capture was not initialized.
  2. capture.set returns 0 if camera is busy (another process using it).

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.

asif
  • 975
  • 8
  • 16
  • To say the truth, I did exactly what you're suggesting. But `set()` returned 0 in both case. I'll try a little spike solution as soon as possible to experiment a little more with that. Maybe I'll try with the Python interface which will be more efficient for testing/prototyping. Thanks. – dom_beau Nov 20 '13 at 13:35
  • OK, I tried with Python and I think the camera was "busy". I retried then it worked. I could set WIDTH, HEIGHT, BRIGHTNESS, SATURATION, GAIN, CONTRAST, EXPOSURE but **not** FPS. Thanks again. – dom_beau Nov 21 '13 at 16:57