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