libuvc_camera是ROS
下的一个软件包,用于将USB摄像头的视频内容发布到Topic
上,但是启动时
roslaunch uvc.launch
经常会遇到以下报错:
process[camera/mycam-1]: started with pid [4578]
unsupported descriptor subtype VS_COLORFORMAT
unsupported descriptor subtype VS_COLORFORMAT
uvc_get_stream_ctrl_format_size: Invalid mode (-51)
[ERROR] [1578882156.980703592]: check video_mode/width/height/frame_rate are available
DEVICE CONFIGURATION (0000:0000/[none]) ---
Status: idle
VideoControl:
bcdUVC: 0x7273
[camera/mycam-1] process has died [pid 4578, exit code -11, cmd /opt/ros/kinetic/lib/libuvc_camera/camera_node __name:=mycam __log:=/home/jeffrey2019/.ros/log/b6a4ed00-35a9-11ea-be20-000c297f47e8/camera-mycam-1.log].
log file: /home/jeffrey2019/.ros/log/b6a4ed00-35a9-11ea-be20-000c297f47e8/camera-mycam-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done
其中
uvc_get_stream_ctrl_format_size: Invalid mode (-51)
给出了报错的关键,指定的工作模式不被摄像头支持,必须找到一种被支持的模式才行。
对于我的戴尔G3 3579笔记本摄像头,我并不知道它支持哪些模式,只好不断试错,最终发现这种可以:
<launch>
<group ns="camera">
<node pkg="libuvc_camera" type="camera_node" name="mycam">
<!-- Parameters used to find the camera -->
<param name="vendor" value="0x0bda"/>
<param name="product" value="0x568a"/>
<param name="serial" value=""/>
<!-- If the above parameters aren't unique, choose the first match: -->
<param name="index" value="0"/>
<!-- Image size and type -->
<param name="width" value="640"/> <!-- 640 -->
<param name="height" value="480"/> <!-- 480 -->
<!-- choose whichever uncompressed format the camera supports: -->
<param name="video_mode" value="uncompressed"/> <!-- or yuyv/nv12/mjpeg -->
<param name="frame_rate" value="30"/>
<param name="timestamp_method" value="start"/> <!-- start of frame -->
<param name="camera_info_url" value="file:///tmp/cam.yaml"/>
<param name="auto_exposure" value="3"/> <!-- use aperture_priority auto exposure -->
<param name="auto_white_balance" value="false"/>
</node>
</group>
</launch>
试错区域集中在Image size and type
区段,包括width
、height
、video_mode
、frame_rate
,每一个参数都必须调整到摄像头恰好支持的配置,不能高也不能低,例如frame_rate
,目前大多数摄像头都有30
,那么libuvc_camera的wiki页面上的默认取值15
就是不对的。
试错成功后,启动下面命令行,就能看到视频流:
rosrun image_view image_view image:=/camera/image_raw