Skip to main content

pyapriltags: Python bindings for the Apriltags library

These are Python bindings for the Apriltags 3 library developed by AprilRobotics. Inspired by the Apriltags2 bindings by Matt Zucker. Forked from dt-apriltags.

The original library is published with a BSD 2-Clause license.

Installation

The easy way

You can install using pip (or pip3 for Python 3):

pip install pyapriltags

And if you want a particular release, add it like this:

pip install pyapriltags@v3.3.0

Build it yourself

Clone this repository and navigate in it. Then initialize the Apriltags submodule:

$ git submodule init
$ git submodule update

Build the Apriltags C library and embed the newly-built library into the pip wheel.

$ make build

The new wheel will be available in the directory dist/. You can now install the wheel

pip install pyapriltags-VERSION-py3-none-ARCH.whl

NOTE: based on the current VERSION of this library and your OS, together with the architecture of your CPU ARCH, the filename above varies.

Release wheels

All the wheels built inside dist/ can be released (pushed to Pypi.org) by running the command

make upload

Release all

Use the following command to build and release wheels for Python 3 and CPU architecture amd64, aarch64 and arm32v7.

make release-all

Usage

Some examples of usage can be seen in the test.py file. The Detector class is a wrapper around the Apriltags functionality. You can initialize it as following:

at_detector = Detector(searchpath=['apriltags'],
                       families='tag36h11',
                       nthreads=1,
                       quad_decimate=1.0,
                       quad_sigma=0.0,
                       refine_edges=1,
                       decode_sharpening=0.25,
                       debug=0)

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 libapriltag.so library. You can find more information on the original Apriltags repository.

Developer notes

The wheel is built inside a Docker container. The Dockerfile in the root of this repository is a template for the build environment. The build environment is based on ubuntu:latest and python3 is installed on the fly. The make build command will create the build environment if it does not exist before building the wheel.

Once the build environment (Docker image) is ready, a Docker container is launched with the following configuration:

  • the root of this repository mounted to /apriltag;
  • the directory dist/ is mounted as destination directory under /out;

The building script from assets/build.sh will be executed inside the container. The build steps are:

  • configure a cmake build in /builds/<arch> from the apriltag library from submodule apriltags/
  • run cmake build
  • copy so/.dylib/.dll library file to /dist/<arch> (inside the container)
  • repeat above steps for: win64, macos arm64, macos x86_64, linux x86_64, linux aarch64, linux armv7l
  • build python wheel (the .so library is embedded as package_data)
  • copy wheel file to /out (will pop up in dist/ outside the container)

Metadata

Release files for pyapriltags 3.4.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyapriltags 3.4.3.1
File
pyapriltags-3.4.3.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pyapriltags-3.4.3.1-py3-none-win32.whl Python 3 none Windows x86-32 Details
pyapriltags-3.4.3.1-py3-none-manylinux_2_31_x86_64.whl Python 3 none Linux glibc 2.31+ x86-64 Details
pyapriltags-3.4.3.1-py3-none-manylinux_2_31_armv7l.whl Python 3 none Linux glibc 2.31+ ARMv7l Details
pyapriltags-3.4.3.1-py3-none-manylinux_2_31_aarch64.whl Python 3 none Linux glibc 2.31+ ARM64 Details
pyapriltags-3.4.3.1-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
pyapriltags-3.4.3.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 8.6 MB

Release files / pyapriltags-3.4.3.1-py3-none-win_amd64.whl

Download URL pyapriltags-3.4.3.1-py3-none-win_amd64.whl
Size 1.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6ac6170964984c994f47f51ce9a3c9a46f3236f95caaf9bcd485c58e233e21a6
BLAKE2b-256 checksum
How to use checksums
e41fbfa31e5a17fcbf4e92283d91b878b48c0a65bd68a90b2e25af0cdc1b740b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-win32.whl

Download URL pyapriltags-3.4.3.1-py3-none-win32.whl
Size 1.3 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
0adb46066d36b22a9634b619fd9ca144f0c40eb2532de2feb9e722685080a18d
BLAKE2b-256 checksum
How to use checksums
64eae6f318a33d80e1f14c40d14a8d52cf8fc77e214713bb8d599bc29ec77abb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-manylinux_2_31_x86_64.whl

Download URL pyapriltags-3.4.3.1-py3-none-manylinux_2_31_x86_64.whl
Size 1.2 MB
Tags Linux glibc 2.31+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c986a014fa5942827aad887e1e7483f2a32ffd0bdf2007da4ada052dd2a3660b
BLAKE2b-256 checksum
How to use checksums
b3f00699a7b34a5fdc860e5dc177b3ee008774f9c9afabdfeed90af90d66f9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-manylinux_2_31_armv7l.whl

Download URL pyapriltags-3.4.3.1-py3-none-manylinux_2_31_armv7l.whl
Size 1.2 MB
Tags Linux glibc 2.31+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
67b2c7078783296fa7c91888777dc1dbb948d8c2dc77e166989f5222910ec853
BLAKE2b-256 checksum
How to use checksums
335be0dc54653777ac498b5056727e2216d0413c0c57932674018595a4ab6822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-manylinux_2_31_aarch64.whl

Download URL pyapriltags-3.4.3.1-py3-none-manylinux_2_31_aarch64.whl
Size 1.2 MB
Tags Linux glibc 2.31+ ARM64 Python 3
SHA-256 checksum
How to use checksums
ad4c42cca2c61e2d2f8ed5300931f1f2651c2afe9cc35ec1e240f51fa00fdca4
BLAKE2b-256 checksum
How to use checksums
8aed48718b2c1b63155e388f6a0b4081f99c10e5e3345771b39e6211d91e9536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-macosx_11_0_x86_64.whl

Download URL pyapriltags-3.4.3.1-py3-none-macosx_11_0_x86_64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
61e0d846357a494eaf3785d054f34860066d90d0c96035c709b116da01c92480
BLAKE2b-256 checksum
How to use checksums
dd62032fad994c00b6e66519ac47747fc72b2c2a3d4290fe1389a9b3e17eb27e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Release files / pyapriltags-3.4.3.1-py3-none-macosx_11_0_arm64.whl

Download URL pyapriltags-3.4.3.1-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d6a13073208eb4344a5d42f2d4ba924a220bff8de74d2afded6d17cb63b94c9e
BLAKE2b-256 checksum
How to use checksums
757e61d605fc806fc2db18b40d4a21826a8ce1ab1650de84c803d0628f94eda3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

Security for pyapriltags 3.4.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pyapriltags-3.4.3.1-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page