annie.media.color¶
Box-drawing colours and frame-overlay rendering (service).
These colours are burned onto the video frames and are distinct from the UI
status chrome in annie.theme. Annie renders overlays with Pillow, which
works in RGB, so colours here are RGB tuples. The numeric values match the
design spec (e.g. blue (0, 0, 255), green (0, 255, 0)); only the
colour-space label differs from the spec’s BGR note, because Annie does not use
OpenCV for drawing.
Drawing rules (from the design):
vdet-only frame — every face box is drawn in flat blue so it does not flicker as detection ordering changes between frames.
tracks available — each track gets a stable colour keyed by
track_id, drawn identically on every frame. The palette excludes the two reserved colours, blue and green.active / protagonist track — always green, overriding its palette colour.
each box is labelled with its
track_idas a small number at the top-left.
Attributes¶
Raw vdet detections. |
|
The active / protagonist track. |
|
Stable palette for ordinary tracks. |
Functions¶
|
Return the stable RGB colour for a track. |
|
Choose the colour for a single box per the four drawing rules. |
|
Draw all boxes (and their track-id labels) for one frame. |
Module Contents¶
- annie.media.color.BLUE = (0, 0, 255)¶
Raw vdet detections.
- annie.media.color.GREEN = (0, 255, 0)¶
The active / protagonist track.
- annie.media.color.TRACK_PALETTE: tuple[tuple[int, int, int], ...] = ((239, 68, 68), (249, 115, 22), (234, 179, 8), (168, 85, 247), (236, 72, 153), (20, 184, 166),...¶
Stable palette for ordinary tracks.
Deliberately excludes blue and green (and anything close to them) so reserved meanings stay unambiguous. Keyed by
track_idmodulo the palette length, so a track is always the same colour.
- annie.media.color.color_for_track(track_id: int, *, active: bool = False) tuple[int, int, int][source]¶
Return the stable RGB colour for a track.
The active (protagonist) track short-circuits to
GREENbefore the palette is consulted; otherwise the colour is a deterministic function oftrack_iddrawn fromTRACK_PALETTE(never blue or green).- Parameters:
track_id – The track index.
active – Whether this is the active / protagonist track.
- Returns:
An
(r, g, b)colour tuple.
- annie.media.color.box_color(box: annie.core.models.BBox, *, has_tracks: bool, active_track_id: int | None) tuple[int, int, int][source]¶
Choose the colour for a single box per the four drawing rules.
- Parameters:
box – The box being drawn.
has_tracks – Whether any track data is available for this frame. When
False(raw vdet only) every box is blue.active_track_id – The resolved active track id, or
None/-1 if none.
- Returns:
The RGB colour to draw the box outline (and its label) in.
- annie.media.color.draw_overlay(frame: numpy.ndarray, annotation: annie.core.models.FrameAnnotation, *, has_tracks: bool, active_track_id: int | None = None, line_width: int = 3) PIL.Image.Image[source]¶
Draw all boxes (and their track-id labels) for one frame.
- Parameters:
frame – The source frame as an HWC
uint8RGB numpy array.annotation – The boxes to draw on this frame.
has_tracks – Whether track data is available (governs blue vs palette).
active_track_id – The active track id to highlight green, or
None.line_width – Outline thickness in pixels.
- Returns:
A new
PIL.Image.Imagewith the overlay drawn on a copy of the frame (the input array is not modified).