Skip to main content

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 Detector from the AprilTag library with customizable settings for tag family, processing threads, decimation, edge refinement, and debug mode.
  • Configuration Flexibility: Offers a nested Config class 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upicvision-0.1.0.6.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upicvision-0.1.0.6-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file upicvision-0.1.0.6.tar.gz.

File metadata

  • Download URL: upicvision-0.1.0.6.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-1022-azure

File hashes

Hashes for upicvision-0.1.0.6.tar.gz
Algorithm Hash digest
SHA256 c4d70e4f897669dcdacc8bb01bbb0fdbc36dd8a6117a806d76a7315db94db57d
MD5 a3b8541937a3c6d31a864101c2a1ef5a
BLAKE2b-256 f7596be9b62f7ab7f9f49b402634b4f56febf7f4bc063d704dd6027f3b33468e

See more details on using hashes here.

File details

Details for the file upicvision-0.1.0.6-py3-none-any.whl.

File metadata

  • Download URL: upicvision-0.1.0.6-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-1022-azure

File hashes

Hashes for upicvision-0.1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5e094e06a33f2ef90dbd09e28b84200c014816a09dcdb09f55959740881fba0e
MD5 afd1d527690a405bb8f9dcdcd2f984d7
BLAKE2b-256 b6a7ae0491ce67772477696d53a955da1c83f83fc264c3488604d27d3f02d5d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page