This module detects AprilTag fiducial markers for camera calibration and pose estimation.
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)
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 coordinatesDetect 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:
cv2 (OpenCV) - Image processingnumpy - Array operationsgettool - Downloads apriltag_detection library automaticallyThe detector automatically checks for and installs the apriltag_detection library using gettool if not found.
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)] |
共 1 个版本