Designing the perfect Apriltag

Posted by Daniel Nugent on

apriltag
At Optitag we give you the freedom to design your Apriltags the way you want. However, this freedom can be intimidating if you're new to Apriltags.

Picking an AprilTag family

Generation

There are 2 generations of AprilTag families, Apriltag 2 and AprilTag 3. AprilTag 2 is the classic Apriltag. Apriltag 2 (gen2) should be used if you want a better out of box experience. It is tried and true and compatible with more software. Apriltag 3 (gen 3) is the newest generation of AprilTag technology. If you want to access to the cool new features (circle tags, recursive tags, faster detections, and higher recall rates) but less software support choose Apriltag 3. 

What about Apriltag 1? Apriltag 1 and 2 are the same tag design, but the algorithm improved from gen 1 to  gen 2. Apriltag generations actually denote the algoritmn generation. It just happened that gen 3 added more functionality and tag families.

Apriltag 2  Apriltag 3
ROS support
OpenCV support ✳️ ✳️
OpenMV support
2x faster detection
More accurate detections
Borderless tags
Circular tags
Recursive tags

✳️ OpenCV doesn't include Apriltag support but the Apriltag Library can be built from source and used with OpenCV. This includes both C and Python bindings 

Family

Once you have picked your Apriltag generation you still need to select a tag family.  Apriltag 2 and Apriltag 3 have different families to choose from. Note: All gen 2 tags are can be used with the gen 3 detector

 Family Generation Unique Tag IDs
16h5 Apriltag 2 30
25h9
Apriltag 2
35
36h11 - recommended
Apriltag 2
587
Circle21h7
Apriltag 3
38
Cirlce49h12
Apriltag 3
65,698
Custom48h12
Apriltag 3
42,211
Standard41h12
Apriltag 3
2,115
Standard52h13 - recommended
Apriltag 3
48,714


Family names can be broken down into 2 numbers. The first number (before the "h") is the number of bits and the second number (after the "h") is the hamming distance. More bits means more tag ids are available in that family. A larger hamming distance allows for more error correction while decoding tag ids. This means if the bits in a tag are read incorrectly, a larger hamming distance allows the tag to be properly identified despite errors. However.a larger hamming distance does reduce the number of available tag ids. i.e. 36h11 would have more available ids than 36h15, but 36h11 would have a higher false positive rate compared to 36h15.

Another thing to keep in mind is the more bits a tag has, the more pixels are required to decode it. This means lower bit tags can be detected further away because they require less resolution to decode. So 25h9 can be detected further away than 36h11 if the tags are the same size. However, 25h9 will have a higher false positive rate.

If you choose Apriltag 3 you have an extra option: family type. Family type allows tags to have flexible layouts. In the image below the dashed line denotes the active regions on the tag. Any bits inside this region are necessary for detecting that tag family. Anything outside this regions doesn't matter. The Circle type allows the tag to be cut in a more circular shape based on its active region. The Custom type allows things to be place in the center of the tag (another tag or a company logo).

Summary

Pick Apriltag 2 if you want maximum software support. Pick Apriltag 3 if you want the newest features and are willing to work with bare bones software.

Apriltag 2: 36h11 is recommended for most applications. It is the most robust tag and has the most tag ids available. Pick 25h9 if you need more distance and are willing to sacrifice robustness and the number of tag ids. Pick 16h5 if you need maximum range and are willing to accept a very high false positive rate and limited tag ids. This family is not recommended unless you have a specific application in mind. If you are attempting to increase detection distance it is recommended you increase your camera's resolution/zoom and increase the tag size before picking 16h5.

Apriltag 3: Standard52h13 is recommended by the creators of Apriltag. It is the most robust tag and has a large number of tag ids available. The Custom48h12 is great for placing logos inside your tags and making drone landing targets (both coming soon to Optitag). Circle49h12 is great if you want a more circular tag (circle cuts coming soon to Optitag).

Extra: Fun tags

Tags usually look random but if you squint hard enough you might see something familiar. 

Calculating optimal size

Calculating the optimal size of your Apriltag usually depends on how far away you want to detect a tag. Before we get into calculating the max distance for a tag distance, I want to mention some caveats with long range detection. Long range detections usually means your tags appears small in an image which results in low resolution detection. This has some pitfalls:

- The tag is less likely it is to get detected

- If detected, the tag is more likely to get identified as another tag id

- If detected, the pose estimate is going to be less accurate

Max detection distance

Max detection distance in meters = t /(2 * tan( (b* f * p) / (2 * r ) ) )

t = size of your tag in meters - Optitag calls this Edge Length or size

= the number of bits that span the width of the tag (excluding the white border for Apriltag 2). ex: 36h11 = 8, 25h9 = 6, standard41h12 = 9

= horizontal FOV of your camera

r = horizontal resolution of you camera

p = the number of pixels required to detect a bit. This is an adjustable constant. We recommend 5. Lowest number we recommend is 2 which is the Nyquist Frequency. We recommend 5 to avoid some of the detection pitfalls mentioned above.

When to add a border extension

At Optitag we allow you to extend the border of your tag. This has a couple benefits: If you plan to hold your tag during use, your fingers will likely wrap around the edge of the tag. This potentially places your fingers in an active region of the tag and may screw up detection of the tag. Yes, the 1 bit white border is necessary for properly detecting the tag. Additionally, if you mount your tag in a frame and the border gets partially covered it may have the same effect. For both these scenarios it is recommended that you extend the border of your tag so the active region stays fully visible.

Material selection

We have a whole blog post on this.

Additional Reading

If you want to learn more about how Apriltags work checkout our other blog posts or see References.

If there is something else you want to see covered leave a comment below.

References 

https://doc.rc-visard.com/latest/en/tagdetect.html

https://github.com/AprilRobotics/apriltag/wiki/AprilTag-User-Guide

https://april.eecs.umich.edu/software/apriltag

 

0 comments

Leave a comment

Please note, comments must be approved before they are published