diff --git a/motmetrics/mot.py b/motmetrics/mot.py index b04fde5..ec7ae59 100644 --- a/motmetrics/mot.py +++ b/motmetrics/mot.py @@ -106,6 +106,7 @@ def __init__(self, auto_id=False, max_switch_time=float('inf')): self.hypHistory = None self.dirty_events = None self.cached_events_df = None + self.last_update_frameid = None self.reset() @@ -121,6 +122,7 @@ def reset(self): self.hypHistory = {} self.dirty_events = True self.cached_events_df = None + self.last_update_frameid = None def _append_to_indices(self, frameid, eid): self._indices['FrameId'].append(frameid) @@ -221,10 +223,10 @@ def update(self, oids, hids, dists, frameid=None, vf=''): self._append_to_events('RAW', np.nan, hid, np.nan) if oids.size * hids.size > 0: - # 1. Try to re-establish tracks from previous correspondences + # 1. Try to re-establish tracks from correspondences in last update for i in range(oids.shape[0]): # No need to check oids_masked[i] here. - if oids[i] not in self.m: + if not (oids[i] in self.m and self.last_match[oids[i]] == self.last_update_frameid): continue hprev = self.m[oids[i]] @@ -322,6 +324,8 @@ def update(self, oids, hids, dists, frameid=None, vf=''): for o in oids: self.last_occurrence[o] = frameid + self.last_update_frameid = frameid + return frameid @property