Skip to main content

Python bindings for apriltags v3

Project description

pupil-apriltags: Python bindings for the apriltags3 library

These are Python bindings for the Apriltags3 library developed by AprilRobotics, specifically adjusted to work with the pupil-labs software. The original bindings were provided by duckietown and were inspired by the Apriltags2 bindings by Matt Zucker.

How to get started:

Install from PyPI

This is the recommended and easiest way to install pupil-apriltags.

$ pip install pupil-apriltags

We offer pre-built binary wheels for common operating systems. In case your system does not match, the installation might take some time, since the native library (apriltags-source) will be compiled first.

Install from source via current master branch from GitHub

$ pip install git+

Manual installation from source

You can of course manually clone the repository and build from there. We use scikit-build instead of the normal python setuptools, since skbuild makes working with native libraries a lot easier. Building is still controlled via standard python [options] commands, but skbuild takes care of platform-independently compiling apriltags-source in the background.


Some examples of usage can be seen in the src/pupil_apriltags/ file.

The Detector class is a wrapper around the Apriltags functionality. You can initialize it as following:

at_detector = Detector(searchpath=['apriltags'],

The options are:

Option Default Explanation
families 'tag36h11' Tag families, separated with a space
nthreads 1 Number of threads
quad_decimate 2.0 Detection of quads can be done on a lower-resolution image, improving speed at a cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still done at full resolution. Set this to 1.0 to use the full resolution.
quad_sigma 0.0 What Gaussian blur should be applied to the segmented image. Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values (e.g. 0.8)
refine_edges 1 When non-zero, the edges of the each quad are adjusted to "snap to" strong gradients nearby. This is useful when decimation is employed, as it can increase the quality of the initial quad estimate substantially. Generally recommended to be on (1). Very computationally inexpensive. Option is ignored if quad_decimate = 1
decode_sharpening 0.25 How much sharpening should be done to decoded images? This can help decode small tags but may or may not help in odd lighting conditions or low light conditions
searchpath ['apriltags'] Where to look for the Apriltag 3 library, must be a list
debug 0 If 1, will save debug images. Runs very slow

Detection of tags in images is done by running the detect method of the detector:

tags = at_detector.detect(img, estimate_tag_pose=False, camera_params=None, tag_size=None)

If you also want to extract the tag pose, estimate_tag_pose should be set to True and camera_params ([fx, fy, cx, cy]) and tag_size (in meters) should be supplied. The detect method returns a list of Detection objects each having the following attributes (note that the ones with an asterisks are computed only if estimate_tag_pose=True):

Attribute Explanation
tag_family The family of the tag.
tag_id The decoded ID of the tag.
hamming How many error bits were corrected? Note: accepting large numbers of corrected errors leads to greatly increased false positive rates. NOTE: As of this implementation, the detector cannot detect tags with a Hamming distance greater than 2.
decision_margin A measure of the quality of the binary decoding process: the average difference between the intensity of a data bit versus the decision threshold. Higher numbers roughly indicate better decodes. This is a reasonable measure of detection accuracy only for very small tags-- not effective for larger tags (where we could have sampled anywhere within a bit cell and still gotten a good detection.)
homography The 3x3 homography matrix describing the projection from an "ideal" tag (with corners at (-1,1), (1,1), (1,-1), and (-1, -1)) to pixels in the image.
center The center of the detection in image pixel coordinates.
corners The corners of the tag in image pixel coordinates. These always wrap counter-clock wise around the tag.
pose_R* Rotation matrix of the pose estimate.
pose_t* Translation of the pose estimate.
pose_err* Object-space error of the estimation.

Custom layouts

If you want to use a custom layout, you need to create the C source and header files for it and then build the library again. Then use the new library. You can find more information on the original Apriltags repository.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pupil-apriltags, version 1.dev0
Filename, size File type Python version Upload date Hashes
Filename, size pupil_apriltags-1.dev0-cp36-cp36m-macosx_10_10_x86_64.whl (8.2 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pupil_apriltags-1.dev0-cp36-cp36m-manylinux2010_x86_64.whl (7.0 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pupil_apriltags-1.dev0-cp36-cp36m-win_amd64.whl (3.7 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pupil_apriltags-1.dev0-cp37-cp37m-macosx_10_10_x86_64.whl (8.2 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pupil_apriltags-1.dev0-cp37-cp37m-manylinux2010_x86_64.whl (7.0 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pupil_apriltags-1.dev0-cp37-cp37m-win_amd64.whl (3.7 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pupil-apriltags-1.dev0.tar.gz (1.9 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page