-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
50 lines (43 loc) · 1.65 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import cv2
from Trackers.centroid_tracker.centroid import Centroid_tracker
from Trackers.iou_tracker.iou import iou_tracker
from Trackers.sort.sort import Sort
from Trackers.iou_pred_tracker.iou_pred import iou_pred_tracker
from Detectors.YOLO import yolo
from Trackers.utility import utility
if __name__ == "__main__":
# Add the arg parser
# load the video
vs = cv2.VideoCapture("/home/aman/Desktop/Airpix/Multi-Camera-Person-Tracking-and-Re-Identification/videos/init/4p-c2.avi")
cfg_file = "Detectors/YOLO/darknet/cfg/yolov4.cfg"
weight_file = "Detectors/YOLO/darknet/yolov4.weights"
namesfile = "Detectors/YOLO/darknet/data/coco.names"
datafile = "Detectors/YOLO/darknet/cfg/coco.data"
class_names="Detectors/YOLO/darknet/data/coco.names"
# Initiate object detector
dect = yolo.Yolo(cfg_file, weight_file,namesfile, datafile)
# Initiate tracker object
# ot = Centroid_tracker()
# ot = iou_tracker()
# ot = iou_pred_tracker()
ot = Sort()
# run the while loop
while True:
# Read frame
ret, frame = vs.read()
if ret!=True:
break
frame = cv2.resize(frame,(640,480))
# run detection and get bbox
detections = dect.detect(frame)
# run tracker update to get tracked tracks
track_list = ot.update(detections)
detections = []
for track in track_list:
detections.append((track.bbox, track.id))
res = utility.draw_box(detections, frame)
cv2.imshow("result",res)
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
vs.release()
break