Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
build
.DS_Store
*.pyc
dist
__pycache__/
*.egg-info
*.so
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
apriltag
========
# apriltag

Small modifications/additions to http://april.eecs.umich.edu/media/apriltag/apriltag-2015-03-18.tgz
## Quick Install

Added a new quad detector and a few various speedups.
This is a quick install script that builds the apriltag library and the python wrapper and installs them onto your system.

```
source ./build_apriltag.sh
```

---

***Please note:*** I am not the maintainer of the pypi package listed at https://pypi.org/project/apriltag/ – GitHub issues filed here reporting problems with that package will be summarily closed. Sorry, I don't have time to support someone else's unofficial package.
Small modifications/additions to http://april.eecs.umich.edu/media/apriltag/apriltag-2015-03-18.tgz

Added a new quad detector and a few various speedups.

**_Please note:_** I am not the maintainer of the pypi package listed at https://pypi.org/project/apriltag/ – GitHub issues filed here reporting problems with that package will be summarily closed. Sorry, I don't have time to support someone else's unofficial package.

Dependencies
============
# Dependencies

- OpenCV (optional)
- OpenCV (optional)

Building
========
# Building

cd /path/to/apriltag
mkdir build
Expand All @@ -26,8 +32,7 @@ If you want to install the library and important binaries to your system directo

sudo make install

Running
=======
# Running

You can run `aprilag_opencv_demo` to do stuff, run with `-h` to get help.

Expand All @@ -38,13 +43,12 @@ So for example, you can run

to benchmark the new code against the old code.

Python
======
# Python

***Note that you must build the software per the instructions above before the Python wrapper can
be used.*** If you did not install the libraries to the system-wide library directory and you
**_Note that you must build the software per the instructions above before the Python wrapper can
be used._** If you did not install the libraries to the system-wide library directory and you
are not running Python code from the python directory in this repository, your Python code
must specify the path for the apriltag shared library when constructing an
must specify the path for the apriltag shared library when constructing an
`apriltag.Detector` object.

I recently added the ability to estimate 3D tag poses to the Python wrapper.
Expand Down
45 changes: 45 additions & 0 deletions build_apriltag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Build script for AprilTag library with Python wrapper
# This script builds the AprilTag library and sets up the Python wrapper for import

set -e # Exit on any error

echo "Building AprilTag library..."

# Create build directory if it doesn't exist
if [ ! -d "build" ]; then
mkdir build
fi

cd build

# Run CMake
echo "Running CMake..."
cmake .. -DCMAKE_BUILD_TYPE=Release

# Build with make
echo "Building with make..."
make -j4

cd ..

# Install Python wrapper globally
echo "Installing Python wrapper globally..."
cd python
python3 setup.py install --user # Install to user site-packages for global access
cd ..

# Test the import
echo "Testing Python import..."
if python3 -c "import apriltag; print('AprilTag Python wrapper imported successfully!')"; then
echo "Build and setup completed successfully!"
echo ""
echo "Usage:"
echo " - Import in Python: import apriltag"
echo " - Create detector: detector = apriltag.Detector()"
echo " - Note: OpenCV is optional and not required for the Python wrapper"
else
echo "Error: Python import failed. Check build output above."
exit 1
fi
3 changes: 3 additions & 0 deletions python/apriltag.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ def __init__(self, options=None, searchpath=[]):
self.libc = None
self.tag_detector = None

if not searchpath:
searchpath = [os.path.dirname(__file__)]

for path in searchpath:
relpath = os.path.join(path, filename)
if os.path.exists(relpath):
Expand Down
39 changes: 39 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python

from setuptools import setup, find_packages
import os
import shutil

# Copy the shared library to the python directory so it can be found
lib_src = os.path.join(os.path.dirname(__file__), '..', 'build', 'lib', 'libapriltag.so')
lib_dest = os.path.join(os.path.dirname(__file__), 'libapriltag.so')

if os.path.exists(lib_src):
shutil.copy2(lib_src, lib_dest)
print(f"Copied {lib_src} to {lib_dest}")
else:
print(f"Warning: {lib_src} not found. Make sure to build the library first.")

setup(
name="apriltag",
version="0.0.1",
author="AprilTag Developers",
description="AprilTag detection library Python wrapper",
long_description="Python wrapper for the AprilTag fiducial marker detection library",
py_modules=["apriltag"],
install_requires=[
"numpy",
],
extras_require={
"opencv": ["opencv-python"],
},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Image Recognition",
],
python_requires='>=3.6',
)