Pywayne Cv Apriltag Detector
Verified@wangyendt
npx machina-cli add skill @wangyendt/apriltag-detector --openclawPywayne AprilTag Detector
This module detects AprilTag fiducial markers for camera calibration and pose estimation.
Quick Start
from pywayne.cv.apriltag_detector import ApriltagCornerDetector
# Create detector
detector = ApriltagCornerDetector()
# Detect from file path
detections = detector.detect('test.png', show_result=True)
# Detect from numpy array
import cv2
image = cv2.imread('test.png')
detections = detector.detect(image)
Detection Methods
detect()
Detect AprilTags in an image:
detections = detector.detect(
image, # File path, Path object, or numpy array
show_result=False # Show visualization window
)
Returns list of detection results with:
id: Tag IDhamming_distance: Detection confidencecenter: Tag center coordinates (x, y)corners: 4 corner coordinates
detect_and_draw()
Detect AprilTags and draw results on original image:
result_image = detector.detect_and_draw(image)
cv2.imshow('Detection Result', result_image)
cv2.waitKey(0)
Visualization includes:
- Green polygon outlines
- Red corner circles
- Red ID labels at tag centers
Requirements
cv2(OpenCV) - Image processingnumpy- Array operationsgettool- Downloads apriltag_detection library automatically
Library Installation
The detector automatically checks for and installs the apriltag_detection library using gettool if not found.
Detection Result Format
Each detection contains:
| Field | Description |
|---|---|
id | Tag identifier |
hamming_distance | Hamming distance (lower = more confident) |
center | Tag center as (x, y) tuple |
corners | 4 corner coordinates as [(x1, y1), (x2, y2), (x3, y3), (x4, y4)] |
Notes
- Supports both grayscale and BGR images
- Automatic grayscale conversion for detection
- Visualization sizes scale with image dimensions
- Uses AprilTag 36h11 tag family
Overview
Pywayne Cv Apriltag Detector detects AprilTag fiducial markers for camera calibration and pose estimation. It uses the ApriltagCornerDetector to find tag corners and IDs, automatically installing the apriltag_detection library via gettool when needed, and can draw results for visualization from both file paths and numpy arrays.
How This Skill Works
Create the detector with ApriltagCornerDetector(), then call detect(image, show_result=...) to obtain detections as a list including id, hamming_distance, center, and corners. For quick visualization, use detect_and_draw(image) which returns an image with green outlines, red corner circles, and red ID labels. If the apriltag_detection library is missing, the detector automatically installs it using gettool.
When to Use It
- Calibrating a camera intrinsics by detecting tag corners in calibration images.
- Estimating camera pose for robotics or drone navigation with Apriltag markers.
- Visual debugging on a live feed or batch images by rendering detections with corners and IDs.
- Working with both file paths and numpy arrays as input without changing code.
- Development where automatic dependency installation via gettool simplifies setup.
Quick Start
- Step 1: from pywayne.cv.apriltag_detector import ApriltagCornerDetector
- Step 2: detector = ApriltagCornerDetector()
- Step 3: detections = detector.detect('test.png', show_result=True)
Best Practices
- Ensure OpenCV (cv2) and NumPy are installed; the detector also auto-installs apriltag_detection if needed.
- Use the default 36h11 tag family as documented for reliable detection.
- Check the hamming_distance field to filter low-confidence detections.
- Prefer detector.detect_and_draw(image) for quick visualization during debugging.
- Pass either a file path or a NumPy array; the API accepts both seamlessly.
Example Use Cases
- Calibrating a camera for a mobile robot by detecting multiple AprilTag corners across calibration images.
- Estimating the robot's pose relative to markers for precise navigation using the tag centers and corners.
- Overlaying tag IDs and outlines in an augmented reality app for real-time marker tracking.
- Processing a dataset of images stored as NumPy arrays to extract tag detections in batch.
- First-run setup that automatically installs apriltag_detection with gettool to simplify deployment.