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
This commit is contained in:
@@ -120,6 +120,30 @@ def run_face_tracker(
|
|||||||
with open(face_json_path) as f:
|
with open(face_json_path) as f:
|
||||||
face_data = json.load(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
|
# V2.0 uses list format (FaceResult), convert to dict for face_tracker
|
||||||
if isinstance(face_data.get("frames"), list):
|
if isinstance(face_data.get("frames"), list):
|
||||||
frames_dict = {}
|
frames_dict = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user