pi vision lib
Project description
upic
TagDetector Class Documentation
Overview
The TagDetector class is designed for real-time detection of AprilTags using a camera feed. It leverages OpenCV and the AprilTag library to identify and track specific tags within the camera's field of view. This class encapsulates functionalities such as camera initialization, AprilTag detection setup, resolution adjustment, and control over the detection process, including start, stop, pause, and resume operations.
Key Features
- AprilTag Detection: Utilizes the
Detectorfrom the AprilTag library with customizable settings for tag family, processing threads, decimation, edge refinement, and debug mode. - Configuration Flexibility: Offers a nested
Configclass to centralize and manage default configurations like operation mode (single tag vs. multiple), resolution scaling, tag ordering strategy, interval for halting checks, and default/error tag IDs. - Camera Management: Provides methods to open, release, and adjust the camera resolution dynamically, ensuring efficient resource handling and适应性to different hardware capabilities and requirements.
- Detection Loop: Implements a threaded detection loop that can be controlled externally to start, halt, and resume tag detection without interrupting the main application flow. This design enables non-blocking operation and responsiveness in applications where real-time feedback is crucial.
- Tag Ordering Strategies: Supports two ordering methods for handling multiple detections: "nearest" (prioritizes the closest tag to the frame center) and "single" (uses the first detected tag), enhancing flexibility based on application needs.
- Error Handling: Includes exception handling within the detection loop to gracefully manage camera failures or unexpected errors during tag processing.
- Property Access: Exposes properties for querying the current detected tag ID and accessing the underlying camera device instance.
Usage Example
Initialization
from upic import TagDetector # Assuming TagDetector is defined in 'your_module'
# Initialize with optional camera ID and custom resolution multiplier
detector = TagDetector(cam_id=0, resolution_multiplier=0.75)
Camera Operations
# Open camera and start detection
detector.open_camera().apriltag_detect_start()
# At any point, you can halt detection without releasing the camera
detector.halt_detection()
# To resume detection after halting
detector.resume_detection()
# When done, release camera resources
detector.release_camera()
Retrieving Detected Tag ID
current_tag_id = detector.tag_id
print(f"Current Tag ID: {current_tag_id}")
Complete code
from upic import TagDetector # Assuming TagDetector is defined in 'your_module'
# Initialize with optional camera ID and custom resolution multiplier
detector = TagDetector(cam_id=0, resolution_multiplier=0.75)
# Open camera and start detection
detector.open_camera().apriltag_detect_start()
# At any point, you can halt detection without releasing the camera
detector.halt_detection()
# To resume detection after halting
detector.resume_detection()
# When done, release camera resources
detector.release_camera()
current_tag_id = detector.tag_id
print(f"Current Tag ID: {current_tag_id}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file upicvision-0.1.0.4.tar.gz.
File metadata
- Download URL: upicvision-0.1.0.4.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.11.9 Linux/6.5.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30b043a51e366e8ddc4e860cebbe457cc3fb92985bc69026a07ea59155ea34cd
|
|
| MD5 |
a8dbeddffb0b511efc0ac2a74802e8c0
|
|
| BLAKE2b-256 |
39d0f63739e0d8119772260630c837e7d388cd6ee3b3516cfcad6a3a721a8774
|
File details
Details for the file upicvision-0.1.0.4-py3-none-any.whl.
File metadata
- Download URL: upicvision-0.1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.11.9 Linux/6.5.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5adbee3bb0e1750211bb5ddd9d587b3089952324fc5487fe9c0f0c5e64da6d37
|
|
| MD5 |
37fa15f64dfc4b6b7b271f5982b0536c
|
|
| BLAKE2b-256 |
016f83fe7a67fd8e25c3e531924d5f808e85d2dc39ca100061830c5590d464d6
|