-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker.py
More file actions
21 lines (17 loc) · 693 Bytes
/
Copy pathtracker.py
File metadata and controls
21 lines (17 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from deep_sort_realtime.deepsort_tracker import DeepSort
class ObjectTracker:
def __init__(self):
self.tracker = DeepSort(max_age=30, n_init=3, max_cosine_distance=0.4)
def update(self, detections, frame):
dets = []
for det in detections:
if len(det) == 6:
x1, y1, x2, y2, conf, cls = det
bbox = [float(x1), float(y1), float(x2), float(y2)]
dets.append([bbox, float(conf), int(cls)])
else:
print("[WARN] Skipping malformed detection:", det)
if not dets:
return []
tracks = self.tracker.update_tracks(dets, frame=frame)
return tracks