Skip to content

Detection Handler

app.ui.handlers.detection_handler

View source code

Detection operations handler for model-based object detection.

See Also

Layer: Presentation. Context: Converts user actions and worker signals into application calls and UI feedback.

DetectionHandler

Bases: QObject

Orchestrates object detection operations and model configuration.

Responsibilities:

  • Handle detection model selection and changes
  • Execute single-frame detection or background detection
  • Manage detection confidence thresholds
  • Filter detections by label selection
  • Update UI view_state based on detection results

Signal Flow:

  • Receives signals from right panel (model selection, detect buttons, confidence changes)
  • Delegates to Application for detection execution
  • Renders frames after detection completion

Layer: Presentation. Context: Supports user interaction and delegates application work through presentation contracts.

__init__(controller: UIController) -> None

controller: UIController supplying detection actions, worker signals, the active window, and frame rendering.

on_chosen_labels_changed(raw: str) -> None

Update selected labels and refilter detections by class.

Triggered By:

RightControlPanel.chosen_labels_changed signal

Flow:

on_chosen_labels_changed(raw) [this slot]: | | ├── Parse comma-separated label string | ├── Update session settings with new chosen_labels | ├── Reapply filtering logic to Layer B | ├── Render frame with filtered boxes | └──> Show tracking warning if tracking data exists

on_detect_current_frame() -> None

Run detection on the current frame of the selected session.

Triggered By: Right panel detect_btn.clicked signal

Flow:

on_detect_current_frame() [this slot]: | | ├──> Set active session | ├──> Call App.detect_current_frame(s_id) | └──> Render updated frame with detection results

on_min_confidence_changed(value: float) -> None

Update the minimum detection confidence-threshold and refilter detections.

Triggered By:

Right panel min_confidence_spinbox.valueChanged signal

Flow:

on_min_confidence_changed(value) [this slot]: | | ├── Update session settings with new min_detection_confidence | ├── Reapply filtering logic to Layer B (detections) | └──> Render frame with filtered boxes

on_start_background_detection() -> None

Start background detection worker for the selected session.

Triggered By: Right panel detect_all_btn.clicked signal

Flow:

on_start_background_detection() [this slot]
  ├── Set active session
  ├── Start DetectionWorker via App (catches WorkerAlreadyRunningException, NullModelNameException)
  └──> Update UI status bar

Error Handling: - Displays error if worker already running for this session - Displays error if no model selected - Updates status bar in finally block