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

uvc_camera gets a terrible image and usb_camera doesn't set framerate

asked 2012-10-31 07:30:30 -0600

Slippery John gravatar image

I have a Logitech c920 webcam that I want to use with ROS. I originally installed uvc_camera, but it gets a terrible quality image from the camera. Then I tried usb_cam, which gets a fantastic quality image, but only at 10fps (which just isn't good enough).

uvc_cam image

usb_camera image

So my question is: How do I get a good image out of uvc OR How do I set frame rate with usb_camera

It should be noted that guvcview gets a fantastic image using the uvc driver, though ros does not.

launch file contents:

FOR usb_cam:
<launch>
    <node name="camera" pkg="usb_cam" type="usb_cam_node" output="screen" >
        <param name="video_device" value="/dev/video1" />
        <param name="image_width" value="1280" />
        <param name="image_height" value="720" />
        <param name="pixel_format" value="yuyv" />
        <param name="camera_frame_id" value="webcam" />
    </node>
</launch>

FOR uvc_camera:
<launch>
  <node ns="camera" pkg="uvc_camera" type="camera_node" name="uvc_camera" output="screen">
    <param name="width" type="int" value="1280" />
    <param name="height" type="int" value="720" />
    <param name="fps" type="int" value="30" />
    <param name="frame" type="string" value="webcam" />
    <param name="device" type="string" value="/dev/video1" />
  </node>
</launch>
edit retag flag offensive close merge delete

Comments

1

I have exactly the same problem with the weird color settings for the uvc_cam. To the slow frame rate of the usb_cam: do you use an usb2.0 port? $lsusb will show you...

dinamex gravatar image dinamex  ( 2012-11-21 06:28:37 -0600 )edit

I have exactly the same problem with a BW analog cam (with USB dongle on video0): vlc shows the video correctly, cheese shows the video correctly, both usb_cam and uvc_camera show purple video with different shades of green/red. No matter what pixfmt parameter I set, they always fall back to YUYV.

Avio gravatar image Avio  ( 2016-09-12 06:35:34 -0600 )edit

After a couple of hours spent fighting with this problem, I solved the issue. I discovered that the correct pixel format for my camera was "uyvy". For future reference, I used this launch file: https://siddhantahuja.wordpress.com/2...

Avio gravatar image Avio  ( 2016-09-12 07:27:18 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-10-27 21:36:48 -0600

sarkar gravatar image

updated 2013-10-27 21:37:49 -0600

Since you have Logitech C920, which has hardware H264 encoding which is an awesome thing. For usb_cam you can try it by changing the value of pixel_format to H264. Change <param name="pixel_format" value="yuyv" /> to <param name="pixel_format" value="H264" />. That should work and you'll get high fps with low resource usage.

edit flag offensive delete link more

Comments

If I do as you suggested I get [FATAL] [1383197110.463584559]: Unknown pixel format. [ERROR] [1383197110.463895717]: VIDIOC_STREAMOFF error 9, Bad file descriptor

Artem gravatar image Artem  ( 2013-10-30 19:27:08 -0600 )edit

Okay uvc_cam accepts it, but the frame rate is still slow.

Artem gravatar image Artem  ( 2013-10-30 23:04:09 -0600 )edit
0

answered 2017-09-10 16:54:26 -0600

chambana gravatar image

I had a similar problem with my c920 and the ros usb_cam node ---- VERY low frame rate (~5fps). On top of that, the H264 option didn't work for my c920 with the usb_cam node. Try these settings, it gave me full frame 1920x1080 with 30fps on usb_cam node. Notice the pixel format is mjpeg. Using these settings, I was able to just rosbag the /usb_cam/image_raw/compressed topic and display it in rviz just fine.

<launch>
  <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video1" />
    <param name="image_width" value="1920" />
    <param name="image_height" value="1080" />
    <param name="pixel_format" value="mjpeg" />
    <param name="camera_frame_id" value="usb_cam" />
    <param name="io_method" value="mmap"/>
  </node>
</launch>
edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2012-10-31 07:30:30 -0600

Seen: 4,409 times

Last updated: Sep 10 '17