Garbled image problem in usb_cam node

109 views
Skip to first unread message

Allen Wong

unread,
Sep 8, 2015, 10:23:50 PM9/8/15
to ros-by-example
I am testing usb_cam_node with a usb camera, when I use the follow launch file, everything is ok,
<launch>
   
<node name="camera" pkg="usb_cam" type="usb_cam_node" output="screen">
       
<param name="video_device" value="/dev/video0" />
       
<param name="image_width" value="640" />
       
<param name="image_height" value="480" />
       
<param name="pixel_format" value="yuyv" />
       
<param name="framerate" value="30" />
       
<param name="camera_frame_id" value="usb_cam" />
       
<param name="io_method" value="mmap" />
       
<param name="camera_info_url" type="string" value="file://$(find pixhawk)/launch/camera.yaml" />
   
</node>

   
<node name="viewer" pkg="image_view" type="image_view" output="screen">
       
<remap from="image" to="/camera/image_raw" />
   
</node>
</launch>

but when I change pixel_format to mjpeg, the video become garbled

 

v4l2-ctl --list-format-ext -d /dev/video0 output:
ioctl: VIDIOC_ENUM_FMT
   
Index       : 0
   
Type        : Video Capture
   
Pixel Format: 'MJPG' (compressed)
   
Name        : MJPEG
       
Size: Discrete 1920x1080
           
Interval: Discrete 0.033s (30.000 fps)
       
Size: Discrete 1280x720
           
Interval: Discrete 0.017s (60.000 fps)
       
Size: Discrete 1024x768
           
Interval: Discrete 0.033s (30.000 fps)
       
Size: Discrete 640x480
           
Interval: Discrete 0.008s (120.101 fps)
       
Size: Discrete 800x600
           
Interval: Discrete 0.017s (60.000 fps)
       
Size: Discrete 1280x1024
           
Interval: Discrete 0.033s (30.000 fps)
       
Size: Discrete 320x240
           
Interval: Discrete 0.008s (120.101 fps)

   
Index       : 1
   
Type        : Video Capture
   
Pixel Format: 'YUYV'
   
Name        : YUV 4:2:2 (YUYV)
       
Size: Discrete 1920x1080
           
Interval: Discrete 0.167s (6.000 fps)
       
Size: Discrete 1280x720
           
Interval: Discrete 0.111s (9.000 fps)
       
Size: Discrete 1024x768
           
Interval: Discrete 0.167s (6.000 fps)
       
Size: Discrete 640x480
           
Interval: Discrete 0.033s (30.000 fps)
       
Size: Discrete 800x600
           
Interval: Discrete 0.050s (20.000 fps)
       
Size: Discrete 1280x1024
           
Interval: Discrete 0.167s (6.000 fps)
       
Size: Discrete 320x240
           
Interval: Discrete 0.033s (30.000 fps)

And the error message:
[mjpeg @ 0x223e460] overread 8
[mjpeg @ 0x223e460] error count: 68
[mjpeg @ 0x223e460] error y=38 x=1
[mjpeg @ 0x223e460] error count: 64
[mjpeg @ 0x223e460] error y=34 x=1
[mjpeg @ 0x223e460] error count: 68
[mjpeg @ 0x223e460] error y=40 x=4
[mjpeg @ 0x223e460] error count: 64
[mjpeg @ 0x223e460] error y=42 x=1
[mjpeg @ 0x223e460] error count: 64
[mjpeg @ 0x223e460] error y=31 x=0
[mjpeg @ 0x223e460] error count: 64
[mjpeg @ 0x223e460] error y=30 x=37

My testing enviroment:
Ubuntu 14.04.3
ROS indigo
I've search almost the whole web, can't figure it out, please help! Thanks!


Patrick Goebel

unread,
Sep 10, 2015, 10:10:00 AM9/10/15
to ros-by-...@googlegroups.com
Hi Allen,

I've never seen that problem myself and I'm definitely not an expert on usb cameras.  I would suggest posting your question on http://answers.ros.org and be sure to include the camera model.  Also, you don't say why you are changing the pixel_format to mjpeg.  Does the image look OK with yuyv?  Be sure to include that info as well.

Good luck!

--patrick
--
The Pi Robot Project
http://www.pirobot.org/wordpress

Allen Wong

unread,
Sep 15, 2015, 2:30:22 AM9/15/15
to ros-by-example
Thanks for your replying! @Pi Robot
Really good suggestion!
I am trying to find solution by reading the source code now, and found the camera is OK, the returned mjpeg stream is no problem, and things become wrong after avcodec_decode_video2() in libavcodec. So I am trying to write another mjpeg decoder or pixel format transformer.

在 2015年9月10日星期四 UTC+8下午10:10:00,Pi Robot写道:
...
Reply all
Reply to author
Forward
0 new messages