To consistently label two specific individuals (Person A and B) in a real-time CPR application using YOLOv11, follow this structured approach:
Maintain a dictionary to track each ID’s "age" (number of consecutive frames it has appeared).
Reset age to 0
if an ID is missing in a frame.
Example data structure:
tracked_persons = {
id: {
"age": int, # Frames since first detection
"last_bbox": list, # [x1, y1, x2, y2]
"last_keypoints": list # Pose keypoints
}
}
age
values) as candidates for A/B.N
frames (e.g., 5 frames).Spatial Heuristic:
candidates = sorted(candidates, key=lambda x: x["last_bbox"][0]) # Sort by x1 of bounding box
person_a = candidates[0]
person_b = candidates[1]
Pose Heuristic (CPR-specific):