Skip to content

Box

app.domain.detection.box

View source code

Base bounding-detection domain dataclass — base core for detection and tracking results.

See Also

Layer: Domain. Context: Defines application concepts independently of UI and infrastructure implementations.

Box dataclass

Shared bounding-detection base for detection and tracking domain results.

ATTRIBUTE DESCRIPTION
item_id

Unique identifier for this detection, e.g. "yolo-42" or "track-7".

TYPE: str

label

Class name of the annotated object, such as "person" or "car".

TYPE: str

bbox_xyxy

Bounding detection (x1, y1, x2, y2) in pixel coordinates.

TYPE: BBoxXYXYTuple

confidence

Confidence score from 0.0 to 1.0.

TYPE: float

color_hex

Display color in #RRGGBB format; defaults to gray "#808080".

TYPE: str

Note

Common fields base by DetectionResult and any future tracking result domain types. Introducing this base eliminates field duplication while preserving clean domain → view boundaries.

Example
detection = Box(
    item_id="yolo-1",
    label="person",
    bbox_xyxy=(10, 20, 100, 200),
    confidence=0.9,
)

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

bbox_xyxy: BBoxXYXYTuple instance-attribute

color_hex: str = '#808080' class-attribute instance-attribute

confidence: float instance-attribute

item_id: str instance-attribute

label: str instance-attribute

__init__(item_id: str, label: str, bbox_xyxy: BBoxXYXYTuple, confidence: float, color_hex: str = '#808080') -> None