Service
app.application.services.detection.serviceDetection service orchestration for model-based object detection across sessions.
See Also
DetectionEngineManager— manages per-session inference enginesDetectionWorkerFactoryAdapter— creates background detection workers
Layer: Application. Context: Coordinates domain state and infrastructure to complete application use cases.
DetectionService
Orchestrates object detection operations and detection engine management.
Responsibilities
- Create and manage
DetectionEngineinstances (one per session, per model). - Execute single-frame detection via
detect_current_frame(). - Start background detection workers for processing entire sessions.
- Apply confidence and label filtering to detection results.
- Store detection results in session data layer.
- Handle model switching and clearing detection layers.
Note
Does not directly create DetectionWorker (delegates to external code).
Manages DetectionEngine lifecycle (creation, model updates).
Filters raw YOLO detections by confidence and chosen labels.
Stores filtered results in DataLayer.B (detection layer).
detect_current_frame() — Single-frame detection (blocking, for UI immediate use).
create_or_update_detection_engine_from_model_name_for_session_id() — Model management.
start_detection_worker_for_session_id() — Background detection (threading).
| PARAMETER | DESCRIPTION |
|---|---|
app
|
Application adapted for session access, model management, detection, and worker coordination.
TYPE:
|
__init__(app: Application) -> None
detect_current_frame_and_populate_layer_b_at_current_index(s_id: SessionId) -> None
Run selected current-frame detection via the execution collaborator.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Session whose current frame should be detected.
TYPE:
|
Raises: Exception: Propagates detection or storage failures.
Note
The ...layer_b... name is a backward-compatible legacy API surface.
Label/confidence-filtered output is stored in Layer A and cloned into
Layer B while preserving manual annotations. The compatibility frame
seeder can still populate Layer B for older data.
Example
service.detect_current_frame_and_populate_layer_b_at_current_index(s_id)
on_detection_batch_ready(s_id: SessionId, batch: dict[int, list[DetectionResult]], batch_processing_time: float) -> None
Runs on the Main Thread safely. Receives batches of detections from the worker and pushes them into the Domain Session.
on_detection_progress_updated(processed_frames: int, total_frames: int, eta_msecs: float | None) -> None
Forward detection progress updates to the UI-facing callback.
| PARAMETER | DESCRIPTION |
|---|---|
processed_frames
|
Number of frames processed so far.
TYPE:
|
total_frames
|
Total number of frames in the detection job.
TYPE:
|
eta_msecs
|
Estimated remaining time in milliseconds, if available.
TYPE:
|
set_detection_model_for_session_id(s_id: SessionId, model_name: str, keep_manual: bool = False) -> None
Sets the detection model for a given session and updates its settings.
start_detection_worker_for_session_id(s_id: SessionId) -> None
Starts a background DetectionWorker .