# AR tag generation

Alvar, the ROS AR tracking package, comes with a feature to automatically generate AR tags. To generate them, you must first install ROS and the ar_track_alvar package.

This can be used from the command line by running rosrun ar_track_alvar createMarker, which will describe the various command line options.

## Script for AR tag generation

This is a script to automatically generate 27 cm AR tags (27 cm black edge to black edge at 96 pixels per centimeter) with 1.5 cm margins on each side and the tag number included. They look like this:

[1]:

#!/usr/bin/env python
from subprocess import call
import cv2
import os

# Marker width in cm border to border
DESIRED_MARKER_SIZE_CM = 27.0

# Size of the white margin around the marker in cm
MARGIN_CM = 1.5

# Marker resolution in pixels per centimeter
PPCM = 96

# Number of units from edge to edge. Ex. a 5x5 AR tag with a 2 unit border has 9 units edge to edge
MARKER_UNIT_SIZE = 9

# Number of pixels per AR tag unit
PIXELS_PER_UNIT = DESIRED_MARKER_SIZE_CM/MARKER_UNIT_SIZE * PPCM

# Size of the white margin around the marker in pixels
MARGIN_PX = int(PPCM*MARGIN_CM)

for marker_number in range(0, 100):
'''
Call ar_track_alvar's generation script.
The syntax is identical to the command line
The marker's number must be last
'''
call(['rosrun', 'ar_track_alvar', 'createMarker', '-u', str(PIXELS_PER_UNIT), str(marker_number)])

# Alvar generates the marker with this name
initial_file_name = "MarkerData_" + str(marker_number) + ".png"

# Save the marker with this name
final_file_name = "Marker_" + str(marker_number) + ".png"

'''
This part adds a margin and adds the number to the lower left margin of the image
'''

# Add a white margin to the marker
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.23934884369373322, "perplexity": 9607.216931001229}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-21/segments/1652662515501.4/warc/CC-MAIN-20220517031843-20220517061843-00086.warc.gz"}