Skip to content

二维码检测

QI_SYSU_pc edited this page May 5, 2021 · 1 revision

二维码检测

本教程的目的:

  • 理解二维码识别程序背后的原理
  • 掌握二维码识别程序,并能够进行二次开发

如何使用

运行以下launch文件

roslaunch prometheus_detection aruco_det_single.launch

可以修改该launchPrometheus/Modules/object_detection/launch/aruco_det_single.launch)文件,调整二维码检测参数

<launch>
    <node pkg="prometheus_detection" type="aruco_det" name="aruco_det" output="screen">
        <param name="camera_topic" type="string" value="/prometheus/camera/rgb/image_raw" />
        <param name="camera_parameters" type="string" value="$(find prometheus_detection)/shell/calib_webcam_640x480.yaml" />
        <param name="output_pose_topic" type="string" value="/prometheus/object_detection/aruco_det" />
        <param name="output_multi_pose_topic" type="string" value="/prometheus/object_detection/multi_aruco_det" />
        <param name="output_image_topic" type="string" value="/prometheus/camera/rgb/image_aruco_det" />
        <param name="dictionary_type" type="int" value="6" />
        <param name="binding_id" type="int" value="1" />
        <param name="target_marker_length" type="double" value="0.025" />
    </node>
</launch>

其中:

  • camera_topic:读取相机话题的节点名称
  • camera_parameters:相机标定参数,一个典型的相机标定参数文件(.yaml)见附录2
  • output_pose_topic:发布检测结果(ArucoInfo.msg)的话题名称,该结果为单个二维码,由binding_id决定
  • output_multi_pose_topic:发布所有检测结果(MultiArucoInfo.msg)的话题名称
  • output_image_topic:发布检测可视化图像话题名称
  • dictionary_type:二维码类型,具体解释见附录1
  • binding_id:单个待检测二维码的ID
  • target_marker_length:待检测二维码的边长,单位m

附录1 二维码类型

可用二维码类型的定义如下

enum  	PREDEFINED_DICTIONARY_NAME {
  DICT_4X4_50 = 0,
  DICT_4X4_100 = 1,
  DICT_4X4_250 = 2,
  DICT_4X4_1000 = 3,
  DICT_5X5_50 = 4,
  DICT_5X5_100 = 5,
  DICT_5X5_250 = 6,
  DICT_5X5_1000 = 7,
  DICT_6X6_50 = 8,
  DICT_6X6_100 = 9,
  DICT_6X6_250 = 10,
  DICT_6X6_1000 = 11,
  DICT_7X7_50 = 12,
  DICT_7X7_100 = 13,
  DICT_7X7_250 = 14,
  DICT_7X7_1000 = 15,
  DICT_ARUCO_ORIGINAL = 16
}

其中DICT是dictionary的缩写,nxn位表示marker标记要被划分的位数,边界为1比特位,所以6x6的marker识别时会被分割为8x8格,如下图所示:

image-20210401170055809

最后一位数字(50,100,250,1000)为字典里编码ID的数量。

附录2 相机标定参数文件

如:Prometheus/Modules/object_detection/shell/calib_webcam_640x480.yaml,内容如下:

%YAML:1.0
---
calibration_time: "2021年01月12日 星期二 18时08分01秒"
image_width: 640
image_height: 480
flags: 0
camera_matrix: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 7.9379415710551370e+02, 0., 2.9783879354295328e+02, 0.,
       7.9491985564466654e+02, 3.0942416136837386e+02, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data: [ 2.0950200339181715e-01, -1.1587468096518483e+00,
       5.5342063671841328e-03, 2.2214393775334758e-04,
       1.7127431916651392e+00 ]
avg_reprojection_error: 2.8342964851391211e-01
Clone this wiki locally