From 5b76b3e647354e046c41b5a48430f21456216bea Mon Sep 17 00:00:00 2001 From: Accusys Date: Sun, 27 Sep 2026 02:38:58 +0800 Subject: [PATCH] fix: store_traced_faces.py skips tracking if trace_id exists - Check if face.json already has trace_id (from Rust face_tracker) - Skip Python tracking if traces already assigned - Prevent duplicate tracking and preserve Rust results - Support both list (FaceResult) and dict formats --- scripts/store_traced_faces.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 = {}