Using the AprilTags Glyph Recognition System

From Lofaro Lab Wiki
Jump to: navigation, search

The Apriltags system is capable of multi-marker recognition.

The following tutorial will help users recognize AprilTag glyphs.

The demo system for AprilTags will allow you to recognize multiple markers and obtain their x, y, and z position as well as their roll, pitch, and yaw.

Prerequisites: Ubuntu

Our tutorials were made using Ubuntu 12.04 LTS.

Getting the AprilTag Recognition Code


Run the following commands to get the AprilTag Recognition code:

   sudo apt-get install subversion cmake libopencv-dev libeigen3-dev libv4l-dev
   sudo port install pkgconfig opencv eigen3
   svn co
   cd apriltags

Printing Tags

In order to recognize the tags, you must first print them. We will be using the tag36h11 family. You can download the png files for this family here.

Now to print a tag, do the following:

1. Untar the tag36h11.tgz file you downloaded

2. Run gimp on one of the png files, e.g., "gimp tag36_11_00000.png"

3. From the pulldown menu, select Image > Scale Image

4. Set the units to inches and the size to your desired tagsize (this tagsize is the length of a side of the tag you wish to print). 3 to 5 inches is a reasonable tagsize.

5. Set the Interpolation mode to None

6. Click on the Scale button

7. From the pulldown menu, select File > Save As

8. Save the image as a PostScript file, e.g., /tmp/

9. Send the PostScript file to your printer


Running the demo

Make sure you have a camera connected before running the demo.

You can run the demo with several options:

 * -h  -?          Show help options
 * -a              Arduino (send tag ids over serial port)
 * -d              Disable graphics
 * -t              Timing of tag extraction
 * -C <bbxhh>      Tag family (default 36h11)
 * -D <id>         Video device ID (if multiple cameras present)
 * -F <fx>         Focal length in pixels
 * -W <width>      Image width (default 640, availability depends on camera)
 * -H <height>     Image height (default 480, availability depends on camera)
 * -S <size>       Tag size (square black frame) in meters
 * -E <exposure>   Manually set camera exposure (default auto; range 0-10000)
 * -G <gain>       Manually set camera gain (default auto; range 0-255)
 * -B <brightness> Manually set the camera brightness (default 128; range 0-255)

By default the tag family that the program recognizes is 36h11, so we will not need to specify that through the options.

If you have multiple cameras connected, you must specify the camera's ID using the -D option.

It is very important that you specify the focal length in pixels of your camera using the -F option. Generally the focal length fx and fy are the same. If they are not, you must edit default fx and fy in the code of the demo program to specify this. It is very important that you have the correct focal length specified in order to obtain accurate pose information of the tag.

-W and -H are used to specify the image resolution that will be input for recognition.

-S is used to specify the tag size in meters, so whatever the length of the side of the tag is in meters is the value you plug in here. It is very important that you have the correct tagsize specified in order to obtain accurate pose information of the tag.

Those are the more important parameters, most of the other parameters are used for faster more optimized recognition.

Here is an example of running the demo for a camera with focal length in pixels of 600, tagsize of 0.2032 meters, image resolution of 640x480, first cd into apriltags then run the following command in the terminal:

   ./build/bin/apriltags_demo -F 600 -S 0.2032 -H 480 -W 640

The AprilTags Demo in Action

The following videos show that the system is capable of single and multi-tag recognition.