diff --git a/scripts/utils/face_tracker.py b/scripts/utils/face_tracker.py index 90cf246..add6943 100755 --- a/scripts/utils/face_tracker.py +++ b/scripts/utils/face_tracker.py @@ -184,8 +184,8 @@ def match_faces( score = 0.0 - # Always reject if embedding similarity is too low (different person) - if use_embedding and curr_emb and prev_emb and similarity < 0.5: + # Reject only if BOTH embedding AND IoU disagree (different person + different position) + if use_embedding and curr_emb and prev_emb and similarity < 0.5 and iou < 0.3: continue # Reject if bbox size changes by more than 5x (e.g., far shot → close-up) @@ -209,6 +209,8 @@ def match_faces( score = iou + similarity elif iou > 0.5 and similarity > 0.65: score = iou * 1.5 + similarity * 0.5 + elif iou > 0.35 and distance < distance_threshold: + score = iou * 2 - distance / 500 elif similarity > 0.85: score = similarity * 2 elif similarity > 0.75 and distance < distance_threshold: