-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker.py
More file actions
33 lines (29 loc) · 821 Bytes
/
tracker.py
File metadata and controls
33 lines (29 loc) · 821 Bytes
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
from deep_sort_realtime.deepsort_tracker import DeepSort
class Tracker:
def __init__(self):
self.object_tracker = DeepSort(
max_age=10,
n_init=3,
nms_max_overlap=0.3,
max_cosine_distance=0.8,
nn_budget=None,
override_track_class=None,
embedder="mobilenet",
# half=True,
bgr=True,
embedder_model_name=None,
embedder_wts=None,
polygon=False,
today=None
)
def track(self, detections, frame):
tracks = self.object_tracker.update_tracks(detections, frame=frame)
tracking_ids = []
boxes = []
for track in tracks:
if not track.is_confirmed():
continue
tracking_ids.append(track.track_id)
ltrb = track.to_ltrb()
boxes.append(ltrb)
return tracking_ids, boxes