annie.media.compose¶
Compose a video’s vdet and track annotations into per-frame overlays (service).
A VideoEntry aggregates one video’s raw detections and all
of its tracks. To draw a frame we merge the relevant boxes into a single
FrameAnnotation, then hand it to
annie.color.draw_overlay(), which colours each box by the standing rules:
vdet boxes (
track_id is None) → flat blue;track boxes → a stable unique colour per track id (never blue/green);
the active / protagonist track → green, overriding its palette colour.
Two inclusion modes are used: the Browse five-frame strip shows vdet + only the active track; the full render shows vdet + every track.
Functions¶
|
Load and index a video's vdet and track annotations by frame. |
|
Combine vdet and selected track boxes for one frame. |
|
Track ids to draw on the Browse strip: just the active one, if any. |
Module Contents¶
- annie.media.compose.load_entry_annotations(entry: annie.core.models.VideoEntry) tuple[dict[int, annie.core.models.FrameAnnotation], dict[int, dict[int, annie.core.models.FrameAnnotation]]][source]¶
Load and index a video’s vdet and track annotations by frame.
- Parameters:
entry – The video whose annotation files to read.
- Returns:
A
(vdet_by_frame, tracks_by_id)pair wherevdet_by_framemaps a frame index to its raw detections, andtracks_by_idmaps each track id to its ownframe_index -> FrameAnnotationmapping.
- annie.media.compose.merge_frame(frame_idx: int, vdet_by_frame: dict[int, annie.core.models.FrameAnnotation], tracks_by_id: dict[int, dict[int, annie.core.models.FrameAnnotation]], include_track_ids: list[int]) annie.core.models.FrameAnnotation[source]¶
Combine vdet and selected track boxes for one frame.
- Parameters:
frame_idx – The frame to assemble.
vdet_by_frame – Per-frame raw detections (from
load_entry_annotations()).tracks_by_id – Per-track per-frame annotations (from
load_entry_annotations()).include_track_ids – Which track ids to include on this frame.
- Returns:
A single
FrameAnnotationholding the vdet boxes followed by the selected track boxes present on that frame.
- annie.media.compose.strip_track_ids(entry: annie.core.models.VideoEntry) list[int][source]¶
Track ids to draw on the Browse strip: just the active one, if any.
- Parameters:
entry – The video being shown.
- Returns:
[active_track_id]when a protagonist is assigned, else[].