Garbled image problem on usb_cam
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] 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
[mjpeg @ 0x223e460] overread 8
My testing enviroment: Ubuntu 14.04.3, ROS indigo
I've search almost the whole web, can't figure it out, please help! Thanks