new_person.set_id(generate_id()) new_person.add_location(person_location) current_people.append(new_person) else: old_person = people_list[person_id] old_person.add_location(person_location) current_people.append(old_person) people_list = current_people # Use this to remove multiple detections # indices =\ # cv2.dnn.NMSBoxes(boxes, confidences, conf_threshold, nms_threshold) # Draw the transition zone zone_start, zone_end = zone.get_limits() cv2.rectangle(frame, zone_start, zone_end, (0, 0, 255), -1) for i, p in enumerate(people_list): location = p.get_last_position() left, top, right, bottom = location cx, cy = (left + right) // 2, (top + bottom) // 2 cv2.putText(frame, '{}'.format(p.get_id()), (cx, cy), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) events = zone.analyse_trajectory_in_zone(p.get_center_trajectory()) if not p.get_check(): if ("OuP" in events) or ("CrP" in events): print("{} crossed the line".format(p.get_id()))