1

I've got a V4L2 camera that can grab frame in JPEG format or YUV422 or BGR24. I'd like to set camera to BGR24@640x480 by OpenCV. To do this, I did the following settings:

capture = cvCreateCameraCapture(0);
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 640 );
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 );
cvSetCaptureProperty( capture, CV_CAP_PROP_FOURCC, CV_FOURCC('B', 'G', 'R', '3'));  

but opencv gives me back the following error message:

HIGHGUI ERROR: V4L: Property <unknown property string>(6) not supported by device

So, openCV set JPEG@640x480 format instead of BGR24. How can I fix it?

NOTE: BGR24 format was tested with the following gstreamer pipeline and it works properly:

gst-launch-0.10 v4l2src num-buffers=10 device=/dev/video0 ! 'video/x-raw-rgb,width=640,height=480,bpp=24,depth=24,red_mask=255,green_mask=65280,blue_mask=16711680,endianness=4321' ! filesink location=/tmp/output10.rgb24

Kind regards

aldo85ita
  • 496
  • 2
  • 8
  • 19

1 Answers1

0

I'd check that you are accessing the correct camera

If you have multiple cameras varying N in cvCreateCameraCapture(N) should cycle through them.

Other than that I would check that the webcam itself conforms to the UVC specification. V4L might be having trouble querying the parameters of the cam.

Just because the Camera supports the capture of a certain format, if it doesn't strictly comply with the Usb Video Class, OpenCV is not guaranteed to be able to detect that it can capture in that format and, to the best of my knowledge, cannot be forced to.

Totero
  • 2,524
  • 20
  • 34
  • Thank you @Totero, I'm sure to using /dev/video0 because I don't have any other plugged camera. My V4L2 camera is not based on UVC because I built the driver for it (It's not a USB camera,it is based on a microcontroller camera interface). Are you sure that CV_CAP_PROP_FOURCC calls standard UVC settings (and not V4L2 ioctls)? – aldo85ita Nov 07 '12 at 11:28
  • For USB Devices the V4L2 calls the UVC (http://www.kernel.org/doc/Documentation/video4linux/uvcvideo.txt) – Totero Nov 07 '12 at 11:31
  • But Seeing how your camera is not USB - a poor assumption by me... Then I would say there is a definite issue between the V4L and your custom driver. Your openCV code is correct. Perhaps you should repost the question as a driver issue (here and on dsp stack) maybe someone has already come across this issue. – Totero Nov 07 '12 at 11:33
  • V4L2 should be more generic than UVC: it can handle different kind of camera (not only USB). UVC is only a sub-layer of V4L2 and it can work only with USB. – aldo85ita Nov 07 '12 at 11:45
  • Yes. That is correct. Again I apologise for assuming your camera was USB. But in my comment I did specify "For USB Devices". I would definitely repost this question as an issue about custom drivers and V4L. There is no OpenCV issue here. – Totero Nov 07 '12 at 11:50