ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
1

How to get usb camera frame?

asked 2015-07-03 09:55:31 -0500

jossy gravatar image

I use ubuntu 14.04 and indigo. I install usb_cam. My launch file is under home/rosbuild_ws/package_dir. The content of it is below :

<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="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="mjpeg" />
    <param name="camera_frame_id" value="usb_cam" />
    <param name="io_method" value="mmap"/>
  </node>
  <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
    <remap from="image" to="/usb_cam/image_raw"/>
    <param name="autosize" value="true" />
  </node>
</launch>

I run below command on terminal and get errors :

~/rosbuild_ws/package_dir$ roslaunch camera.launch

Unable to open camera calibration file [/home/user/.ros/camera_info/head_camera.yaml]
[ WARN] [1435933649.952842400]: Camera calibration file /home/user/.ros/camera_info/head_camera.yaml not found.
 [ INFO] [1435933649.952876387]: Starting 'head_camera' (/dev/video1) at 640x480 via mmap (mjpeg) at 30 FPS
 [ WARN] [1435933649.984525524]: unknown control 'white_balance_temperature_auto'

 [ WARN] [1435933649.987070582]: unknown control 'focus_auto'

 [ERROR] [1435933650.169146261]: Webcam: expected picture but didn't get it...
 [ERROR] [1435933650.200955971]: Webcam: expected picture but didn't get it...
 [ERROR] [1435933650.232933986]: Webcam: expected picture but didn't get it...

How can I get rgb camera frame and show in ros-indigo?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-03 11:36:32 -0500

cyborg-x1 gravatar image

updated 2015-07-04 06:24:51 -0500

Maybe the mode you selected is not supported by the camera or the node. I have some problem with that too. I could not get to use libuvc_camera to give me an mjpeg stream with 30 fps in my desired resolution. I always struggled even with other tools. Just vlc worked for me so far.

You can list supported formats by:

v4l2-ctl --list-formats-ext -d /dev/video0

UPDATE:

I tried usb_cam with mine now. It seems to work perfectly for me:

    <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="1280" />
        <param name="image_height" value="720" />
        <param name="pixel_format" value="mjpeg" />
        <param name="camera_frame_id" value="usb_cam" />
        <param name="io_method" value="mmap"/> 
      </node>   
    </launch>

Found it here

So I guess I will probably use usb_cam instead of libuvc_camera.

(btw not mjpg -> mjpeg)

UPDATE2:

I checked the code for the io_method and the formats supported by the node:

io_methods: mmap, read, userptr

formats: yuyv, uyvy, mjpeg, yuvmono10, rgb24

UsbCam::pixel_format UsbCam::pixel_format_from_string(const std::string& str)
{
    if (str == "yuyv")
      return PIXEL_FORMAT_YUYV;
    else if (str == "uyvy")
      return PIXEL_FORMAT_UYVY;
    else if (str == "mjpeg")
      return PIXEL_FORMAT_MJPEG;
    else if (str == "yuvmono10")
      return PIXEL_FORMAT_YUVMONO10;
    else if (str == "rgb24")
      return PIXEL_FORMAT_RGB24;
    else
      return PIXEL_FORMAT_UNKNOWN;
}
edit flag offensive delete link more

Comments

I run the command for /dev/video1, result of it is Index : 1 Type : Video Capture Pixel Format: 'MJPG' (compressed) Name : MJPEG When I set pixel value mjpg , I get Unknown pixel format 'mjpg'

jossy gravatar imagejossy ( 2015-07-04 00:51:10 -0500 )edit

I set pixel value as yuyv, it works with video0 and video1. But the command says video0 pixel type is yuyv and video1 pixel type is mjpg.

jossy gravatar imagejossy ( 2015-07-04 00:55:28 -0500 )edit

See my update above, that works for me.

cyborg-x1 gravatar imagecyborg-x1 ( 2015-07-04 06:07:31 -0500 )edit

What is the output of v4l2-ctl --list-formats-ext -d /dev/video0 ? Maybe you could also check for the io_method, read is not supported for my camera, while userptr and mmap work.

cyborg-x1 gravatar imagecyborg-x1 ( 2015-07-04 06:30:04 -0500 )edit

Tried another camera, I got the same error like you "Webcam: expected picture but didn't get it..." then I retried with another io_method and it started working.

cyborg-x1 gravatar imagecyborg-x1 ( 2015-07-04 16:50:45 -0500 )edit

the output of v4l2-ctl --list-formats-ext -d /dev/video0 is Index:0 Pixel Format: 'YUYV' .... Index:1 Index : 1 Type : Video Capture Pixel Format: 'MJPG' (compressed). I tried to run with 'yuyv' and it works .

jossy gravatar imagejossy ( 2015-07-06 00:37:05 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-07-03 09:55:31 -0500

Seen: 3,770 times

Last updated: Jul 04 '15