yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Realsense Depth Camera📖
1.Installation video
  • Installation video
2.Tutorials
  • 2.0 How to use camera
  • 2.1 Opencv application
  • 2.2 Color recognition-object tracking
  • 2.3 ARTag
  • 2.4 ROS+Opencv basic course
  • 2.5 ROS+OpenCV application
  • 2.6 Data conversion and point cloud
Download
  • Code
  • Datasheet
  • Software
  • VM file
Download ZIP

Welcome to Realsense Depth Camera repository

2.3 ARTag

3、ARTag

3、ARTag3.1、Overview3.2、Create ARTag3.2.1、Install software pack3.2.2、Create AR QR Code3.3、ARTag recognition3.3.1、ar_track_alvar node3.3.2、launch file parsing3.3.3、Start up camera to to recognize3.3.4、View node graph3.3.5、View tf tree3.3.6、Viewing output information

3.1、Overview

wiki:http://wiki.ros.org/ar_track_alvar/

source code:https://github.com/ros-perception/ar_track_alvar.git

ARTag (AR tag, AR means "augmented reality") is a fiducial marking system, which can be understood as a reference for other objects. It looks similar to a QR code, but its coding system and QR code are difference, it is mostly used in camera calibration, robot positioning, augmented reality (AR) and other applications.

One of the most important functions is to recognize the pose relationship between the object and the camera. ARTag can be affixed to the object, or an ARTag label can be affixed to the flat surface to calibrate the camera. After the camera recognizes ARTag, it can calculate the position and posture of the tag in camera coordinates.

ar_track_alvar has 4 function:

  • Generate AR tags of different sizes, resolutions and data/ID encoding.
  • Recognize and track the pose of a single AR tag, and optionally integrate kinect depth data (when kinect is available) for better pose estimation.
  • Recognize and track the pose of a "bundle" composed of multiple tags. This allows for more stable pose estimation, robustness to occlusion, and tracking of multilateral objects.
  • Use camera images to automatically calculate the spatial relationship between the tags in the bundle, so that users do not have to manually measure and enter the tag position in the XML file to use the bundle function.

Alvar is newer and more advanced than ARToolkit. ARToolkit has always been the basis of several other ROS AR label packages. Alvar has adaptive threshold processing to handle various lighting conditions, optical flow-based tracking to achieve more stable pose estimation, and an improved tag recognition method that does not slow down significantly as the number of tags increases.

 

3.2、Create ARTag

3.2.1、Install software pack

sudo apt install ros-melodic-ar-track-alvar

image-20210902154213121

ar_track_alvar is an open source marker library that provides examples of pr2+kinect.

3.2.2、Create AR QR Code

  • Continuously generate multiple labels on one picture
xxxxxxxxxx
rosrun ar_track_alvar createMarker

image-20210902164850255

You can enter [ID] and location information here, and enter [-1] to end. One or more can be generated, and the layout can be designed by yourself.

image-20210902165006781

  • Generate a single number

Command + parameters directly generate digital pictures; for example

xxxxxxxxxx
rosrun ar_track_alvar createMarker 11
rosrun ar_track_alvar createMarker -s 5 33 

11: The number is the QR code of 11.

s: Specify the image size.

5: 5x5 picture.

33: The number is 33 QR code.

3.3、ARTag recognition

Note: When starting the camera, you need to load the camera calibration file, otherwise it will not be recognized.

3.3.1、ar_track_alvar node

  • Subscribed topic
TopicData type
/camera_info(sensor_msgs/CameraInfo)
/image_raw(sensor_msgs/Image)
  • Published Topics
TopicData type
/visualization_marker(visualization_msgs/Marker)
/ar_pose_marker(ar_track_alvar/AlvarMarkers)
  • Provided tf Transforms

Single QR code: Camera coordinate system → AR label coordinate system

Multiple QR codes: Provide the transformation from the camera coordinate system to each AR tag coordinate system (named ar_marker_x), where x is the ID number of the marker.

3.3.2、launch file parsing

xxxxxxxxxx
<launch>
    <!-- Set camDevice parameters, the default is USBCam ->
    <arg name="camDevice" default="USBCam" doc="camDevice type [Astra,USBCam]"/>
    <arg name="open_rviz" default="true"/>
    <arg name="marker_size" default="5.0"/>
    <arg name="max_new_marker_error" default="0.08"/>
    <arg name="max_track_error" default="0.2"/>
    <!--Set camera image topic, camera internal parameter topic, camera frame -->
    <arg name="cam_image_topic" default="/camera/rgb/image_raw" if="$(eval arg('camDevice') == 'Astra')"/>
    <arg name="cam_info_topic" default="/camera/rgb/camera_info" if="$(eval arg('camDevice') == 'Astra')"/>
    <arg name="output_frame" default="/camera_link" if="$(eval arg('camDevice') == 'Astra')"/>
    <arg name="cam_image_topic" default="/usb_cam/image_raw" unless="$(eval arg('camDevice') == 'Astra')"/>
    <arg name="cam_info_topic" default="/usb_cam/camera_info" unless="$(eval arg('camDevice') == 'Astra')"/>
    <arg name="output_frame" default="/usb_cam" unless="$(eval arg('camDevice') == 'Astra')"/>
  
    <include if="$(eval arg('camDevice') == 'Astra')" file="$(find astra_camera)/launch/astrapro.launch"/>
    <include unless="$(eval arg('camDevice') == 'Astra')" file="$(find usb_cam)/launch/usb_cam-test.launch"/>
    <!-- Set the correspondence between the camera coordinate system and the world coordinate system-->
    <node  if="$(eval arg('camDevice') == 'Astra')" pkg="tf" type="static_transform_publisher" name="world_to_cam"
          args="0 0 0.5 0 0 0 world camera_link 10"/>
    <node  unless="$(eval arg('camDevice') == 'Astra')" pkg="tf" type="static_transform_publisher" name="world_to_cam"
          args="0 0 0.5 0 1.57 0 world usb_cam 10"/>
    <!-- Start AR recognition node-->
    <node name="ar_track_alvar" pkg="ar_track_alvar" type="individualMarkersNoKinect" respawn="false" output="screen">
        <param name="marker_size" type="double" value="$(arg marker_size)"/>
        <param name="max_new_marker_error" type="double" value="$(arg max_new_marker_error)"/>
        <param name="max_track_error" type="double" value="$(arg max_track_error)"/>
        <param name="output_frame" type="string" value="$(arg output_frame)"/>
        <remap from="camera_image" to="$(arg cam_image_topic)"/>
        <remap from="camera_info" to="$(arg cam_info_topic)"/>
    </node>
    <!-- start up rviz -->
    <group if="$(arg open_rviz)">
        <node pkg="rviz" type="rviz" name="rviz" args="-d $(find transbot_visual)/rviz/ar_track.rviz"/>
    </group>
</launch>

Node parameters:

  • marker_size (double) -- The width in centimeters of one side of the black square marker border
  • max_new_marker_error (double) -- A threshold determining when new markers can be detected under uncertainty
  • max_track_error (double) -- A threshold determining how much tracking error can be observed before an tag is considered to have disappeared
  • camera_image (string) -- The name of the topic that provides camera frames for detecting the AR tags. This can be mono or color, but should be an UNrectified image, since rectification takes place in this package
  • camera_info (string) -- The name of the topic that provides the camera calibration parameters so that the image can be rectified
  • output_frame (string) -- The name of the frame that the published Cartesian locations of the AR tags will be relative to

3.3.3、Start up camera to to recognize

xxxxxxxxxx
 roslaunch transbot_visual ar_track.launch camDevice:=Astra
  • camDevice:If you are using an ORBBEC camera, the parameter is Astra, Otherwise it is USBCam

image-20210902194448055

In rviz, you need to set the corresponding camera topic name.

  • Image_Topic:ORBBEC camera is [/camera/rgb/image_raw], high frame rate camera is [/usb_cam/image_raw].
  • Marker:The display component of rviz. Different squares show the location of the AR QR code.
  • TF:The display component of rviz, which be used to display the coordinate system of the AR QR code.
  • Camera:The display component of rviz, which displays the camera screen.
  • world:World coordinate system.
  • usb_cam/camera_link:Camera coordinate system.

3.3.4、View node graph

xxxxxxxxxx
rqt_graph

image-20210902204026973

3.3.5、View tf tree

xxxxxxxxxx
rosrun rqt_tf_tree rqt_tf_tree  

image-20210902203913123

Through rviz, we can see the relative position of the QR code and the camera very intuitively.

3.3.6、Viewing output information

xxxxxxxxxx
rostopic echo /ar_pose_marker

The following information is displayed:

xxxxxxxxxx
    header: 
      seq: 0
      stamp: 
        secs: 1630584915
        nsecs: 196221070
      frame_id: "/usb_cam"
    id: 3
    confidence: 0
    pose: 
      header: 
        seq: 0
        stamp: 
          secs: 0
          nsecs:         0
        frame_id: ''
      pose: 
        position: 
          x: 0.0249847882514
          y: 0.0290736736336
          z: 0.218054183012
        orientation: 
          x: 0.682039034537
          y: 0.681265739969
          z: -0.156112715404
          w: 0.215240718735
  • frame_id:Name of the camera's coordinate system
  • id:The recognized number is 3
  • pose:Pose of the QR code
  • position:The position of the QR code coordinate system relative to the camera coordinate system
  • orientation:The orientation of the QR code coordinate system relative to the camera coordinate system

 

Color recognition-object tracking
ROS+Opencv basic course

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文