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

Issue with usb_cam, can't open camera

asked 2012-09-03 06:34:24 -0600

lanray gravatar image

updated 2014-01-28 17:13:32 -0600

ngrennan gravatar image

I wanna to test whether this usb_cam works. But get the error below. Anyone can help? THX!!

@Laptop:~/ros_workspace/usb_cam$ roslaunch usb_cam-test.launch
... logging to /home/lanray/.ros/log/cb16e5d0-f5e3-11e1-bc19-001e64868dfe/roslaunch-Laptop-18031.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server <a href="http://Laptop:56876/">http://Laptop:56876/</a>


 * /image_view/autosize
 * /rosdistro
 * /rosversion
 * /usb_cam/camera_frame_id
 * /usb_cam/image_height
 * /usb_cam/image_width
 * /usb_cam/io_method
 * /usb_cam/pixel_format
 * /usb_cam/video_device

    image_view (image_view/image_view)
    usb_cam (usb_cam/usb_cam_node)


core service [/rosout] found
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
process[usb_cam-1]: started with pid [18051]
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
process[image_view-2]: started with pid [18062]
usb_cam video_device set to [/dev/video0]
usb_cam io_method set to [mmap]
usb_cam image_width set to [640]
usb_cam image_height set to [480]
usb_cam pixel_format set to [mjpeg]
usb_cam auto_focus set to [0]
VIDIOC_S_FMT error 22, Invalid argument
[usb_cam-1] process has died [pid 18051, exit code 1, cmd /home/lanray/ros_workspace/usb_cam/bin/usb_cam_node __name:=usb_cam __log:=/home/lanray/.ros/log/cb16e5d0-f5e3-11e1-bc19-001e64868dfe/usb_cam-1.log].
log file: /home/lanray/.ros/log/cb16e5d0-f5e3-11e1-bc19-001e64868dfe/usb_cam-1*.log
edit retag flag offensive close merge delete


please post questions with useful titles and useful tags so that others can learn from your issues too.

Kevin gravatar image Kevin  ( 2012-09-03 06:47:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-09-03 07:19:22 -0600

Hi there,

I have had a similar error some time back and I decided to google for the right solution before posting my own question. Fortunately, I got the answer straight and simple from the following link:

ROS Answers

However, to simply state the solution here all you have to do is to set the parameter pixel_format to 'yuyv' from its default value of 'mjpeg'

This could be done in the terminal by executing the following line before executing the 'rosrun' command:

rosparam set /usb_cam/pixel_format yuyv

and then,

rosrun usb_cam usb_cam_node

I have used this with several webcam and it worked fine in all of them. You may even make a launch file with this parameter set to 'yuyv' so that you need not repeat the command everytime you run usb_cam_node.

Am sure this will work.

Good luck with your task to achieve.


edit flag offensive delete link more


To have an even more convenient way to handle this, you could create a small custom launch file for usb_cam that sets this parameter.

Christoph gravatar image Christoph  ( 2013-11-01 23:15:25 -0600 )edit

how to set the parameter in a launch file @Christoph ?

I tried this, but it didn't work:

  <param name="/usb_cam/pixel_format" value="yuyv"/>
rflmota gravatar image rflmota  ( 2014-09-20 19:17:34 -0600 )edit

I have tried this solution however the problem still occurs sometimes. The camera is used for tracking an April Tag on the quad-copter and it is dangerous when the camera node suddenly stops working in the middle of flight. I am using Logitech Pro 9000 PC Internet Camera Webcam. Alternate solution?

aorait gravatar image aorait  ( 2016-03-21 13:55:07 -0600 )edit

Question Tools


Asked: 2012-09-03 06:34:24 -0600

Seen: 10,021 times

Last updated: Oct 31 '13