Commit fe31d68a authored by Mohammed Azzam M.A's avatar Mohammed Azzam M.A

Upload New File

parent 9162fb2b
from __future__ import print_function
import numpy as np
from kalman_tracker import KalmanBoxTracker
from data_association import associate_detections_to_trackers
class Sort:
def __init__(self, length, std, max_age=20, min_hits=5):
NOTE: The number of objects returned may differ from the number of detections provided.
"""
self.frame_count += 1
# Get predicted locations from existing trackers.
trks = np.zeros((len(self.trackers), 5))
to_del = []
ret = []
for t, trk in enumerate(trks):
pos = self.trackers[t].predict(img) #for kal!
trk[:] = [pos[0], pos[1], pos[2], pos[3], 0]
trk.update([], img)
d = trk.get_state()
# print(d)
if ((trk.time_since_update <= self.max_age) and (trk.hit_streak >= self.min_hits or self.frame_count <= self.min_hits)):
ret.append(np.concatenate((d,[trk.id+1])).reshape(1,-1))
i -= 1
# Remove dead tracklet
if trk.time_since_update > self.max_age:
self.trackers.pop(i)
if len(ret) > 0:
return np.concatenate(ret)
return np.empty((0, 7))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment