Skip to content

Box Io

app.shared.box_io

View source code

Module for box io; provides reusable helpers across application layers.

See Also
  • BBoxViewModel — the view-model shape serialized by these helpers
  • BoxSource — source values included in serialized boxes

Layer: Shared utilities. Context: Provides reusable helpers across application layers at this architectural boundary.

box_to_dict(box: BBoxViewModel) -> dict[str, object]

Serialize a box view model to a JSON-compatible mapping.

PARAMETER DESCRIPTION
box

Bounding box whose fields are serialized.

TYPE: BBoxViewModel

RETURNS DESCRIPTION
dict[str, object]

Mapping containing the box ID, source, label, coordinates, color, confidence, and key.

dict_to_box(data: dict[str, object]) -> BBoxViewModel

Build a box view model from its serialized fields.

PARAMETER DESCRIPTION
data

Mapping with id, source, label, bbox_xyxy, and color_hex; confidence and key are optional.

TYPE: dict[str, object]

RETURNS DESCRIPTION
BBoxViewModel

Box view model populated from the mapping.