ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

USB_Cam, Could not open MJPEG Decoder

asked 2011-07-09 06:06:20 -0500

davidcw gravatar image

Whenever I run usb_cam with pixel_format:="mjpeg", I get the following error:

usb_cam video_device set to [/dev/video1]
usb_cam pixel_format set to [mjpeg]
[mjpeg @ 0x7fabe40f0160]codec type or id mismatches
Could not open MJPEG Decoder
Segmentation Fault

I'm using a Logitech Webcam Pro 9000, on Ubuntu 11.04, with the latest "usb_cam" downloaded from the bosch-ros-pkg repository. usb_cam works great when I set pixel_format to "yuyv", and I can see the image with image_view. However, the frame rates for "mjpeg" should be 4x higher than "yuyv" at this camera's native resolution (according to the list at ). I would ultimately like to use this webcam to track a 'fast' moving target, one that I should be able to catch at 30fps, but not reliably catch 5-7.5 fps.

I've installed ffmpeg and libavcodec-dev from Ubuntu's software center. I'd be happy to supply any additional information, but I'm not sure what to look for.

  • Thanks!
edit retag flag offensive close merge delete


The link below: seems broken. Does anyone has an answer to this? Same problem here. I am using Indigo, usb_cam and Ubuntu 14.04.

cvcook gravatar image cvcook  ( 2015-07-09 20:46:22 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2011-08-31 09:58:10 -0500

mgb gravatar image

I fixed up CvCaptureCAM_DShow to allow MJPG and setting of all the webcam parameters. Fixes are against 2.3.0 see

edit flag offensive delete link more

answered 2011-09-05 20:52:09 -0500

rado0x54 gravatar image

updated 2011-09-05 20:56:32 -0500

Patch your usb_cam.cpp. This should fix the error.

--- usb_cam.cpp (revision 628)
+++ usb_cam.cpp (working copy)
@@ -296,6 +296,7 @@
   avpicture_alloc((AVPicture *)avframe_rgb, PIX_FMT_RGB24, image_width, image_height);

   avcodec_context->codec_id = CODEC_ID_MJPEG;
+  avcodec_context->codec_type = AVMEDIA_TYPE_VIDEO;
   avcodec_context->width = image_width;
   avcodec_context->height = image_height;
edit flag offensive delete link more

Question Tools


Asked: 2011-07-09 06:06:20 -0500

Seen: 2,272 times

Last updated: Sep 05 '11