Skip to content

Bounding Box View Model

app.domain.views.bounding_box_view_model

View source code

Module for bounding box view model; defines application concepts without UI or infrastructure dependencies.

See Also
  • Box — domain geometry represented by the view model
  • DetectionResult — detection output converted to this view model

Layer: Domain. Context: Defines application concepts without ui or infrastructure dependencies at this architectural boundary.

BBoxViewModel dataclass

Bounding detection display model — binds detection/tracking/manual detection to UI table row.

ATTRIBUTE DESCRIPTION
id

Display ID, such as "yolo-1" or "track-42".

TYPE: str

source

Origin, e.g. AnnotationBoxSource.DETECTION, AnnotationBoxSource.MANUAL.

TYPE: BoxSource

label

Class name, such as "person" or "car".

TYPE: str

bbox_xyxy

Coordinates (x1, y1, x2, y2) in pixels.

TYPE: BBoxTuple

color_hex

Display color in #RRGGBB format.

TYPE: str

confidence

Score from 0.0 to 1.0, or None for manual boxes.

TYPE: float

key

Unique key for selection and editing.

TYPE: str

detection_backed

Whether the tracker observed a detection on this frame.

TYPE: bool

time_since_update

Number of consecutive frames since a detection matched.

TYPE: int

Note

Stored in SessionDataStore and displayed in the UI table for the current frame. confidence_txt and bbox_txt expose formatted display values, and clone() provides a fast shallow copy.

Layer: Domain. Context: Represents application concepts without UI or infrastructure dependencies.

bbox_txt: str property

Format box coordinates for display.

RETURNS DESCRIPTION
str

Coordinate string in (x1, y1), (x2, y2) format.

bbox_xyxy: BBoxXYXYTuple instance-attribute

color_hex: str instance-attribute

confidence: float instance-attribute

confidence_txt: str property

Format confidence for display in the annotation table.

RETURNS DESCRIPTION
str

Confidence rounded to two decimal places, or "N/A" when absent.

detection_backed: bool = True class-attribute instance-attribute

id: str instance-attribute

is_detection: bool property

Return whether the box originated from detection.

RETURNS DESCRIPTION
bool

True when the box source is detection.

is_manual: bool property

Return whether the box was created manually.

RETURNS DESCRIPTION
bool

True when the box source is manual.

key: str = '' class-attribute instance-attribute

label: str instance-attribute

source: BoxSource instance-attribute

time_since_update: int = 0 class-attribute instance-attribute

__init__(id: str, source: BoxSource, label: str, bbox_xyxy: BBoxXYXYTuple, color_hex: str, confidence: float, key: str = '', detection_backed: bool = True, time_since_update: int = 0) -> None

clone() -> 'BBoxViewModel'

Create an independent shallow copy of this bounding box.

RETURNS DESCRIPTION
'BBoxViewModel'

A box with identical identity, geometry, and tracking observation metadata.

Note

The tuple geometry and scalar metadata are immutable values and are copied by assignment; later field replacement does not affect the original.

Example

editable = box.clone()