import base64 import json from pathlib import Path import numpy as np from pose_tracking_exp.common.joints import BODY20_INDEX_BY_NAME from pose_tracking_exp.common.normalization import normalize_coco_body20, normalize_rtmpose_body20 from pose_tracking_exp.detection.cvmmap_payload import ( COCO_WHOLEBODY_KEYPOINT_COUNT, PROTOCOL_HEADER, CvmmapPosePayloadCodec, convert_payload_record, decode_pose_payload, ) from pose_tracking_exp.schema.detection import PoseDetections from pose_tracking_exp.tracking import load_replay_file, load_scene_file, synchronize_frames def _encode_payload( *, frame_index: int, reference_size: tuple[int, int], boxes: np.ndarray, box_scores: np.ndarray, keypoints_xy: np.ndarray, keypoint_scores: np.ndarray, timestamp_unix_ns: int, ) -> bytes: return ( PROTOCOL_HEADER + int(frame_index).to_bytes(4, "little") + np.asarray(reference_size, dtype="