annie.parsers.base¶
Shared CSV schema and the parser protocol.
Both .vdet and .track files use one identical 17-column schema with a
header row and CRLF line endings:
frame_id, source, score, x, y, w, h,
left_eye_x, left_eye_y, right_eye_x, right_eye_y,
nose_x, nose_y, left_mouth_x, left_mouth_y, right_mouth_x, right_mouth_y
The source column is informational only — matching is done by file stem, not
by this path (it points at the original capture location, which need not exist).
Attributes¶
The 17 columns of the shared detection/track CSV schema, in order. |
Classes¶
Protocol implemented by every annotation loader. |
Functions¶
|
Read a shared-schema CSV into a list of column-keyed dict rows. |
|
Build a |
|
Group flat CSV rows into per-frame annotations, sorted by frame index. |
Module Contents¶
- annie.parsers.base.CSV_COLUMNS: tuple[str, ...] = ('frame_id', 'source', 'score', 'x', 'y', 'w', 'h', 'left_eye_x', 'left_eye_y', 'right_eye_x',...¶
The 17 columns of the shared detection/track CSV schema, in order.
- class annie.parsers.base.AnnotationParser[source]¶
Bases:
ProtocolProtocol implemented by every annotation loader.
A parser turns a path into a list of
FrameAnnotation, one entry per distinctframe_idit contains.- __call__(path: str | pathlib.Path) list[annie.core.models.FrameAnnotation][source]¶
Parse
pathinto per-frame annotations.- Parameters:
path – Path to the annotation file.
- Returns:
One
FrameAnnotationper distinct frame index.
- annie.parsers.base.read_csv_rows(path: str | pathlib.Path) list[dict[str, str]][source]¶
Read a shared-schema CSV into a list of column-keyed dict rows.
Tolerant of both CRLF and LF line endings (
newline=""letscsvhandle either) and of a UTF-8 BOM. The header row is required and is used as the dict keys.- Parameters:
path – Path to the CSV file.
- Returns:
One dict per data row, keyed by column name.
- Raises:
FileNotFoundError – If
pathdoes not exist.
- annie.parsers.base.parse_bbox_row(row: dict[str, str], track_id: int | None = None) annie.core.models.BBox[source]¶
Build a
BBoxfrom one CSV row.- Parameters:
row – A column-keyed dict as produced by
read_csv_rows().track_id – The owning track id to stamp onto the box, or
Nonefor a raw detection.
- Returns:
The parsed bounding box, with its five named landmarks populated.
- annie.parsers.base.group_rows_by_frame(rows: list[dict[str, str]], track_id: int | None = None) list[annie.core.models.FrameAnnotation][source]¶
Group flat CSV rows into per-frame annotations, sorted by frame index.
Multiple rows sharing a
frame_id(possible in a.vdet) collapse into a singleFrameAnnotationcarrying all their boxes.- Parameters:
rows – Column-keyed CSV rows from
read_csv_rows().track_id – Track id to stamp on every box, or
Nonefor raw detections.
- Returns:
Per-frame annotations ordered by ascending
frame_idx.