From Tekkotsu Wiki

Revision as of 15:56, 29 June 2011 by Touretzky (Talk | contribs)
Jump to: navigation, search

AprilTags are an implementation of Augmented Reality Tags from Edwin Olson's APRIL Laboratory at the University of Michigan. They are visual markers designed for robust detection by machines.


Background Information

See AprilTag: A robust and flexible multi-purpose fiducial system for a description of the algorithm. See the ARTag.net web site for information about earlier implementations of the augmented reality tag idea, and the ARToolKit page for information about a currently popular implementation. Here are some YouTube demo videos. And here are the two 2004 technical reports by Mark Fiala describing his ARTag implementation: NRC-47166 and NRC-47419. There is also a book about use of ARTag: Augmented Reality: A Practical Guide.

Printing Your Own AprilTags

The tag16h5 and tag36h11 tag families can be found in /usr/local/Tekkotsu/Vision/AprilTags. To print out your own tags, first cd to one of those directories. Then:

  1. Run gimp on one of the png files, e.g., "gimp tag16h5_00000.png"
  2. From the pulldown menu, select Image > Scale Image
  3. Set the units to inches and the size to your desired size (typically 3 to 5 inches)
  4. Set the Interpolation mode to None (this is crucial)
  5. Click on the Scale button
  6. From the pulldown menu, select File > Save As
  7. Save the image as a PostScript file, e.g., /tmp/tag0.ps
  8. Send the PostScript file to your printer

Running the TagTest Demo

The first four AprilTags in the 36h11 series. This image can be used with the TagTest demo.

Follow the AprilTags install instructions to install the TagTest demo. To run the demo, type /usr/local/april/bin/tagtest. Click on the "Debug" checkbox and then control-right click on the display and go to "Select Buffers" to call up a menu of display options. Click on the "Detach" menu item. You can also click-and-drag in the 3D display (the right half of the main window) to rotate the view.

A few sample 36h11 tags are shown at right. this is the tag family that the TagTest demo recognizes. The name 36h11 indicates that these are 36 bit tags (6x6 array) with a minimum Hamming distance of 11 bits between codes. There are 518 tags in this tag family.

Using AprilTags With Tekkotsu

See the AprilTest demo and Lab: AprilTags for instructions on using AprilTags with Tekkotsu.

How the Algorithm Works

The algorithm has nine steps:

  1. Convert the image to floating point grayscale (pixel values between 0.0 and 1.0) and apply a Gaussian blur.
  2. Calculate the local gradient (magnitude and direction) at each pixel.
  3. Generate a list of edges, grouping connected pixels with similar directions together. An edge is present if the magnitude of the gradient for both pixels is significantly above zero.
  4. Create clusters from the edges.
  5. Loop over the clusters, fitting lines called Segments.
  6. For each Segment, find segments that begin where this segment ends.
  7. Search all connected segments to find loops of length 4, called Quads. Each quad represents the black border around a tag candidate.
  8. Decode the quads by looking at the pixels inside the border to see if they represent a valid tag code, and generate a list of TagDetections
  9. Search for overlapping TagDetections and take the best ones (lowest Hamming distance or largest perimeter); discard the rest.

Generating Your Own AprilTags

To generate .png files for each tag in the 36h11 family, use the following commands:

cd /usr/local/april/java
export CLASSPATH=/usr/local/april/java/april.jar
java april.tag.TagFamily april.tag.Tag36h11 /tmp/tag36h11

You can then use a program like gv to display /tmp/tag36h11/alltags.ps, or use gimp or display to show the mosaic.png file or one of the individual tag .png files.

To generate a new tag family, such as the 16h5 family (the default family used by Tekkotsu), use the following commands:

cd /usr/local/april/java
java april.tag.TagFamilyGenerator 16 5 >/tmp/Tag16h5.java

Install the file Tag16h5.java in /usr/local/april/java/src/april/tag and then use the instructions above to generate the alltags.ps file and individual .png files.