Skip to content

Commit

Permalink
fix bug when re-establish tracks: only consider match in last update …
Browse files Browse the repository at this point in the history
…to (#127)

avoid neglecting ID TRANSFER and provide totally consistent result from
matlab toolbox.
  • Loading branch information
shensheng27 authored Sep 28, 2023
1 parent 89dbe32 commit 8c25d76
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions motmetrics/mot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8c25d76

Please sign in to comment.