版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24894159/article/details/82939542
ROS中UVC_Camera的使用
最近新买了usb摄像头,发现用usb_cam来启动始终无法调到1280*760模式,试着改过了pixel_format为mjpeg也不行。这里最后终于探索出一条解决方法。
步骤(主要参考wiki libuvc_camera)
- 安装libuvc ,
sudo apt-get install ros-kinetic-libuvc-camera
; - 确认usb的
idVendor
和idProduct
,Terminal 执行 lsusb
, 查看到你摄像头对应的信息,比如:Bus 002 Device 002: ID 05a3:9422 ARC International
那么,idVendor
为0x05a3
,idProduct
为0x9422
。 - 写启动文件:这里不再通过
device /dev/video0
来指定摄像头了,而是通过idVendor
和idProduct
来访问了。
<launch>
<group ns="camera">
<node pkg="libuvc_camera" type="camera_node" name="mycam">
<!-- Parameters used to find the camera -->
<param name="vendor" value="0x05a3"/>
<param name="product" value="0x9422"/>
<param name="serial" value="3"/>
<!-- If the above parameters aren't unique, choose the first match: -->
<param name="index" value="0"/>
<!-- Image size and type -->
<param name="width" value="1280"/>
<param name="height" value="720"/>
<!-- choose whichever uncompressed format the camera supports: -->
<param name="video_mode" value="mjpeg"/> <!-- 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://$(find usb_cam)/example.yaml"/>
<param name="auto_white_balance" value="true"/>
</node>
</group>
<node pkg="image_view" type="image_view" name="image_view_test" output="screen">
<remap from="image" to="/camera/image_raw"/>
</node>
</launch>
这里需要注意width/height/video_mode
需要正确对应。如我的摄像头不支持yuyv/1280/720
4. roslaunch
,OK,你可能会遇到报错,Permission denied /etc/bus/usb/002/006...
5. 赋予权限:sudo chmod o+w /etc/bus/usb/002/006
这里填被拒绝的端口。
6. 然后就OK啦,可以显示了。