Ask Your Question

bernizt's profile - activity

2017-06-21 11:02:14 -0500 received badge  Famous Question (source)
2016-10-15 06:06:36 -0500 received badge  Notable Question (source)
2016-03-03 13:58:06 -0500 received badge  Popular Question (source)
2014-09-13 10:28:15 -0500 received badge  Editor (source)
2014-09-13 06:55:36 -0500 asked a question Changing pixel format (YUYV to MJPG) when capturing from webcam?

Hello,

I am having problems when capturing from a logitech c270 using OpenCV 2.4.2. The only working resolution is 800 x 600, as OpenCV also sets pixel format to MJPG. When the application is running, the command v4l2-ctl -V prints:

Format Video Capture:
    Width/Height  : 800/600
    Pixel Format  : 'MJPG'
    Field         : None
    Bytes per Line: 0
    Size Image    : 816000
    Colorspace    : SRGB

With any other resolution the application freezes and v4l2-ctl -V prints (resolution matches the selected one):

Format Video Capture:
    Width/Height  : 640/480
    Pixel Format  : 'YUYV'
    Field         : None
    Bytes per Line: 1280
    Size Image    : 614400
    Colorspace    : SRGB

The following commands work:

cap.set(CV_CAP_PROP_FRAME_WIDTH,800); cap.set(CV_CAP_PROP_FRAME_HEIGHT,600);

But trying to change any other parameter with the set commands throws a:

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

I have been searching for a solution but I have had no luck. If I could capture, for example, 640 * 480 in MJPG (which v4l2-ctl --list-formats-ext shows as supported by my camera) would OpenCV work? How can I change pixel format inside OpenCV?

Edit: The following command v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=1 gives the expected result, I want to do the same action in OpenCV.

Thank you very much,


USB Camera: Logitech c270 Resolutions: various Pixel formats: YUYV and MJPG (checked with the command v4l2-ctl --list-formats-ext)

Beaglebone OpenCV 2.4.2 (default version in Angstrom Distribution)