From cbfa809dad50b772a6b8db8890fffec7a41b4a2a Mon Sep 17 00:00:00 2001 From: kezaidan <448649255@qq.com> Date: Thu, 29 Oct 2020 17:57:52 +0800 Subject: [PATCH] fix bug when re-establish tracks: only consider match in last update to avoid neglecting ID TRANSFER and provide totally consistent result from matlab toolbox. --- motmetrics/mot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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