Viewer Module
This module provides the Viewer class for capturing and decoding barcodes and QR codes from video streams. It uses OpenCV for video capture and pyzbar for decoding.
- class VisionCommon.viewer.Viewer(camera_index: int = 0)
Bases:
objectViewer for capturing and scanning frames
- __init__(camera_index: int = 0) None
Initialize the viewer with a specified camera index.
- Parameters:
camera_index (int) – Index of the camera. Defaults to 0.
- capture_code(timeout_sec: int = None, timeout_frame: int = None, code_types: Iterable[ZBarSymbol] = None) str | None
Captures codes based on timeout constraints.
- Parameters:
timeout_sec (int, optional) – Maximum time in seconds.
timeout_frame (int, optional) – Maximum frame count.
code_types (Iterable[ZBarSymbol], optional) – Types of codes to decode.
- Raises:
ValueError – For negative timeouts.
InvalidCombinationException – If no timeout is set.
- Returns:
Decoded content, or None.
- Return type:
Optional[str]
- capture_frame() ndarray | None
Captures a single frame from the camera.
- Returns:
Captured frame, or None.
- Return type:
Optional[ndarray]