Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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)

click to hide/show revision 2
added tags and additional information

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)