Skip to content

Layer

app.application.services.detection.layer

View source code

Detection layer (Layer B) CRUD operations and filtering.

See Also

Layer: Application. Context: Coordinates domain state and infrastructure to complete application use cases.

DetectionLayerService

Bases: QObject

Manages user-editable detection layer (DataLayer.B) operations.

Responsibilities
  • CRUD operations for DataLayer.B bounding boxes.
  • Manual detection creation (Create).
  • Copy detections to adjacent frames (Update).
  • Apply confidence and label filtering to detections (Update).
  • Reset detections (revert to DataLayer.A) (Update).
  • Delete detections by key (Delete).
Note

DataLayer.A — Raw immutable detection output (cannot edit). DataLayer.B — User-editable detections (seeded from A, filtered by settings). Filters applied via confidence-threshold and chosen-labels list. All user edits are in Layer B only.

Data Flow: Detection Model (YOLO, Torch, etc.) → DataLayer.A (raw output). Apply Filters (confidence, labels) → DataLayer.B (filtered). User Edits (add, delete, move, relabel) on DataLayer.B. Export DataLayer.B to video.

PARAMETER DESCRIPTION
app

Application adapted for session lookup and manual or filtered detection-layer updates.

TYPE: Application

__init__(app: Application) -> None

add_manual_box_to_layer_b_at_current_frame_index(s_id: SessionId, label: str, bbox_xyxy: BBoxXYXYTuple, color_hex: str = '#00ff00') -> None

Add a manually-drawn bounding detection to the current frame in Layer B.

PARAMETER DESCRIPTION
s_id

Session ID.

TYPE: SessionId

label

Object class label (e.g., "person", "car").

TYPE: str

bbox_xyxy

Tuple (x1, y1, x2, y2) in pixel coordinates.

TYPE: BBoxTuple

color_hex

Optional color for display (default green).

TYPE: str DEFAULT: '#00ff00'

Note
  • Creates BBoxViewModel with confidence=1.0 (user confidence).
  • Assigns unique manual ID via next_annotation_id counter.
  • Adds to current frame's Layer B.
  • Increments detection ID counter for next manual detection.