poseinterface.io.annotations_to_coco#
- poseinterface.io.annotations_to_coco(input_path, output_json_path, *, coco_image_filenames=None, coco_visibility_encoding='ternary')[source]#
Export annotations file from a single video to
poseinterfaceformat.- Parameters:
input_path (
Path) – Path to the input annotations file.output_json_path (
Path) – Path to save the outputposeinterfaceCOCO JSON file.coco_image_filenames (
str|list[str] |None) – Optional image filenames to use in theposeinterfaceCOCO JSON. If provided, must be a single string (for single-frame videos) or a list of strings matching the number of labeled frames. If None (default), generates filenames from video filenames and frame indices.coco_visibility_encoding (
str) – Encoding scheme for keypoint visibility in theposeinterfaceCOCO JSON file. Options are “ternary” (0: not labeled, 1: labeled but not visible, 2: labeled and visible) or “binary” (0: not visible, 1: visible). Default is “ternary”.
- Returns:
Path to the saved
poseinterfaceCOCO JSON file.- Return type:
Notes
The format of the input annotations file is automatically inferred based on its extension. See
sleap_io.io.main.load_file()for supported formats.See also
sleap_io.io.coco.convert_labelsThe underlying function used to convert SLEAP labels to COCO format.
Example
>>> from pathlib import Path >>> from poseinterface.io import annotations_to_coco >>> coco_json_path = annotations_to_coco( ... input_path=Path("path/to/annotations.slp"), ... output_json_path=Path("path/to/annotations_coco.json"), ... )