使用ROS的usb_cam包
准备工作:测试设备
- 使用VLC进行测试
安装VLC:
sudo apt install vlc
运行后点击Media->Open Capture Device,在Capture Device界面的Video device name中选择相机,如/dev/video0
,Audio device name留空,Video standard保留默认的Undefined,然后点击Play
配置
-
安装
sudo apt-get install ros-$ROS_DISTRO-usb-cam
-
测试
rosrun usb_cam usb_cam_node
图像将被发送至/usb_cam/image_raw
-
通过Launch启动摄像头
<launch> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="/dev/video0" /> <param name="image_width" value="1280" /> <param name="image_height" value="720" /> <param name="pixel_format" value="yuyv" /> <param name="framerate" value="30" /> <param name="autofocus" value="false" /> <param name="focus" value="0" /> <param name="contrast" value="32" /> <param name="brightness" value="32" /> <param name="saturation" value="32" /> <param name="sharpness" value="22" /> <param name="focus" value="0" /> <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>
其它
- 备注
head_camera is the frame_id being published by the camera_info topic of usb_cam by default. Even though the name is specified, it doesn’t exist until you define it.