diff --git a/scripts/store_traced_faces.py b/scripts/store_traced_faces.py index 358226a6..b2ed165f 100644 --- a/scripts/store_traced_faces.py +++ b/scripts/store_traced_faces.py @@ -120,6 +120,30 @@ def run_face_tracker( with open(face_json_path) as f: face_data = json.load(f) + # Check if faces already have trace_id (from Rust face_tracker) + frames_to_check = face_data.get("frames", {}) + if isinstance(frames_to_check, list): + # List format (FaceResult) + has_trace = any( + face.get("trace_id") is not None + for frame in frames_to_check + for face in frame.get("faces", []) + ) + else: + # Dict format (legacy) + has_trace = any( + face.get("trace_id") is not None + for frame_data in frames_to_check.values() + for face in frame_data.get("faces", []) + ) + + if has_trace: + print(f"[TRACE] face.json already contains trace_id, skipping tracking") + # Copy face.json to traced_json_path (no re-tracking needed) + import shutil + shutil.copy(face_json_path, traced_json_path) + return traced_json_path + # V2.0 uses list format (FaceResult), convert to dict for face_tracker if isinstance(face_data.get("frames"), list): frames_dict = {}