ros使用usb摄像头追踪ArUco markers
先上效果图
知识点
ArUco:基于OpenCV的增强现实程序使用的最小库
增强现实技术(Augmented Reality,简称 AR)
ros wiki上是这样说的:
http://wiki.ros.org/aruco_ros
The ARUCO Library has been developed by the Ava group of the Univeristy of Cordoba(Spain). It provides real-time marker based 3D pose estimation using AR markers.
aruco库由科尔多瓦大学(西班牙)的AVA组开发。它使用AR标记,提供了基于三维位姿实时估计的标记。
Uco 是Univeristy of Cordoba缩写,当然理解为Utility Compiler 实用编译程序也很有意思
官方的链接
http://www.uco.es/investiga/grupos/ava/node/26
ArUco markers可理解为视觉识别程序使用的标记
标记类似二维码
如下图
在ros中可以利用它实现机器人视觉导航,但首先得用摄像头识别这种标记,如何实现?
具体步骤这篇文章有介绍:
原文链接
http://sauravag.com/2015/03/how-to-tracking-aruco-marker-using-a-usb-webcam-and-ro/
引用过来翻译一下,并做一些注意点的说明。
How To: Tracking ArUco markers using a USB Webcam and ROS
ros如何使用usb摄像头追踪ArUco markers
For my research I needed to setup ROS to use ArUco so that I could track these ArUco markers placed randomly in the environment and localize my robot.
Assuming that you have your catkin workspace setup, here are the steps:
经我研究,需要设置ROS使用aruco才能让我追踪这些随机放置在环境中的aruco标记并定位机器人。
假设你有你的工作空间,这里的步骤:
1. $cd ~/catkin_ws/src/
2. $git clone https://github.com/pal-robotics/aruco_ros.git
3. $cd ..
4. $catkin_make install
5. $sudo apt-get install ros-indigo-usb-cam
6. $source install/setup.bash
7. $cd src/aruco_ros/aruco_ros/launch/
Now you need to modify the single.launch file so that you remap the image and camera info to the topics published by usb_cam node.
现在你需要修改single.launch文件,重新映射 通过usb_cam节点发布的image和camera_info主题。
<launch><arg name=”markerId” default=”582″/>
<arg name=”markerSize” default=”0.034″/> <!– in m –>
<arg name=”eye” default=”left”/>
<arg name=”marker_frame” default=”aruco_marker_frame”/>
<arg name=”ref_frame” default=””/> <!– leave empty and the pose will be published wrt param parent_name –>
<node pkg=”aruco_ros” type=”single” name=”aruco_single”><!-- 注意这里 -->
<remap from=”/camera_info” to=”/usb_cam/camera_info” />
<remap from=”/image” to=”/usb_cam/image_raw” /><param name=”image_is_rectified” value=”True”/>
<param name=”marker_size” value=”$(arg markerSize)”/>
<param name=”marker_id” value=”$(arg markerId)”/>
<param name=”reference_frame” value=”$(arg ref_frame)”/> <!– frame in which the marker pose will be refered –>
<param name=”camera_frame” value=”stereo_gazebo_$(arg eye)_camera_optical_frame”/>
<param name=”marker_frame” value=”$(arg marker_frame)” />
</node></launch>
8. Open 4 terminal windows:
开四个终端分别运行命令:
Terminal 1: $roscore
Terminal 2: $roslaunch usb_cam-stream.launch
First paste this into a new file named usb_cam-stream.launch:
先要把下面的代码粘贴到usb_cam-stream.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=”640″ />
<param name=”image_height” value=”480″ />
<param name=”pixel_format” value=”mjpeg” />
<param name=”camera_frame_id” value=”usb_cam” />
<param name=”io_method” value=”mmap”/>
</node>
</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="640" /><param name="image_height" value="480" /><param name="pixel_format" value="yuyv" /><param name="camera_frame_id" value="usb_cam" /><param name="io_method" value="mmap"/></node>
Terminal 3:
$cd ~/catkin_ws/src/aruco_ros/aruco_ros/launch/
$roslaunch single.launch
Terminal 4: $rosrun image_view image_view image:=/aruco_single/result
怎样制作一个ArUco marker?
这个网页实现了一个在线的生成器,效果不错。
http://terpconnect.umd.edu/~jwelsh12/enes100/markergen.html
ArUco markers Generator
ArUco markers 生成器
This form will create an HTML page containing a marker that is compatible with the Aruco marker detection algorithm.
Marker Id: the unique id that will be encoded in the marker image.
Marker Size: the edge size of the black box containing the marker.
Marker Padding: the thickness of the white border surrounding the marker.
这个表单将创建包含标记的一个html页面,其算法与aruco标记检测算法兼容。
Marker Id:标记图像编码的唯一id。
Marker Size:包含标记黑框边的尺寸。
Marker Padding:标记填充一圈白色边框的厚度。
这里需要根据上文提到的single.launch文件里的参数来制作这个ArUco marker
<arg name=”markerId” default=”582″/>
<arg name=”markerSize” default=”0.034″/> <!– in m –>
提交表单后你就会在页面中看到一个mark图,可以打印出来了。
同时在这个launch文件设置自己usb camera 标定参数。
缺少标定会有transform的错误出现
设置标定参数的代码
<param name="camera_info_url" value="package://usb_cam/launch/calibration_webcam.yaml"/>
此时打开终端launch一下,你就能看到开篇的图了。
其他参考
How to create markers for ARUCO?
http://iplimage.com/blog/create-markers-aruco/
[OpenCV] aruco Markers识别
http://blog.csdn.net/ZJU_fish1996/article/details/72312514?locationNum=7&fps=1
基于arucoTag的简单slam
http://blog.csdn.net/u010566411/article/details/54692254