Add object detection, tracking, mobile notifications, and search to any security camera.
track id in test draw
Rory Clear3258f7b963f9
diff --git a/test/test_mot.py b/test/test_mot.pyindex 8ab5dca..53f2110 100644--- a/test/test_mot.py+++ b/test/test_mot.py@@ -12,7 +12,7 @@ if __name__ == "__main__":jit_cache = {}size = "t"- draw = False+ draw = Trueclass_labels = fetch('https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names').read_text().split("\n")Path('./test_outputs').mkdir(parents=True, exist_ok=True)cap = cv2.VideoCapture("test/videos/MOT16-03.mp4")@@ -35,7 +35,7 @@ if __name__ == "__main__":for x in online_targets:if x.tracklet_len < 1 or x.speed < 2.5: continueif x.class_id == 0 and x.track_id not in ppl: ppl.add(x.track_id)- preds.append(np.array([x.tlwh[0], x.tlwh[1], x.tlwh[0] + x.tlwh[2], x.tlwh[1] + x.tlwh[3], x.score, x.class_id]))+ preds.append(np.array([x.tlwh[0], x.tlwh[1], x.tlwh[0] + x.tlwh[2], x.tlwh[1] + x.tlwh[3], x.score, x.class_id, x.track_id]))print("ppl =",len(ppl))if draw:_, buffer = cv2.imencode(".jpg", im0)diff --git a/utils/helpers.py b/utils/helpers.pyindex b5ffc6c..fe14d2c 100644--- a/utils/helpers.py+++ b/utils/helpers.py@@ -87,19 +87,16 @@ def draw_bounding_boxes(orig_img_path, predictions, class_labels):object_count = defaultdict(int)for pred in predictions:- if len(pred) == 7: # todo- x1, y1, x2, y2, conf, class_id, _ = pred- else:- x1, y1, x2, y2, conf, class_id = pred+ if len(pred) == 7: x1, y1, x2, y2, conf, class_id, track_id = predif conf == 0:continue- x1, y1, x2, y2, class_id = map(int, (x1, y1, x2, y2, class_id))+ x1, y1, x2, y2, class_id, track_id = map(int, (x1, y1, x2, y2, class_id, track_id))color = color_dict[class_labels[class_id]]cv2.rectangle(orig_img, (x1, y1), (x2, y2), color, box_thickness)- label = f"{class_labels[class_id]} {conf:.2f}"+ label = f"{class_labels[class_id]} {track_id}"text_size, _ = cv2.getTextSize(label, font, font_scale, 1)label_y, bg_y = ((y1 - 4, y1 - text_size[1] - 4)