Skip to content

Worker Interface

app.application.interfaces.detection.worker_interface

View source code

Interface contract for background detection worker implementations.

See Also

Layer: Application. Context: Defines protocol boundaries consumed by application orchestration.

DetectionWorkerInterface

Bases: Protocol

Abstraction boundary for background YOLO/ML detection worker threads.

Implementations must be startable, stoppable, and expose cached detection results per frame index. Signals (batch_ready, progress_updated, etc.) remain on the concrete class and are connected by the orchestrating service; they are intentionally outside this minimal interface.

Layer: Application. Context: Coordinates use-case behavior through domain services and application contracts.

batch_ready = SignalInstance class-attribute instance-attribute

error_occurred = SignalInstance class-attribute instance-attribute

finished_processing = SignalInstance class-attribute instance-attribute

progress_updated = SignalInstance class-attribute instance-attribute

get_all_detections() -> dict[int, list[DetectionResult]]

Return a copy of all cached detections keyed by frame index.

RETURNS DESCRIPTION
dict[int, list[DetectionResult]]

New dictionary mapping processed frame indices to detection results.

get_detections(frame_index: int) -> list[DetectionResult] | None

Return cached detections for frame_index, or None if not yet processed.

PARAMETER DESCRIPTION
frame_index

Zero-based index of the frame to query.

TYPE: int

RETURNS DESCRIPTION
list[DetectionResult] | None

Detections cached for the frame, or None if no result is available.

isRunning() -> bool

Return True while the worker thread is processing frames.

RETURNS DESCRIPTION
bool

True while the detection worker thread is active.

is_complete() -> bool

Return True after the full frame stream has been processed.

RETURNS DESCRIPTION
bool

True once the worker has processed the complete frame stream.

start() -> None

Start the detection thread.

stop() -> None

Request the detection thread to stop.