Skip to content

Commit 22483cb

Browse files
Lihi-Gur-Arielihi
andauthored
fixed a bug (#181)
Co-authored-by: lihi <[email protected]>
1 parent 0708b3f commit 22483cb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

motmetrics/mot.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,19 @@ def update(self, oids, hids, dists, frameid=None, vf=''):
257257

258258
o = oids[i]
259259
h = hids[j]
260-
is_switch = (o in self.m and
261-
self.m[o] != h and
262-
abs(frameid - self.last_occurrence[o]) <= self.max_switch_time)
260+
######################################################################
261+
# todo - fixed a bug:
262+
# is_switch = (o in self.m and
263+
# self.m[o] != h and
264+
# abs(frameid - self.last_occurrence[o]) <= self.max_switch_time)
265+
switch_condition = (
266+
o in self.m and
267+
self.m[o] != h and
268+
o in self.last_occurrence and # Ensure the object ID 'o' is initialized in last_occurrence
269+
abs(frameid - self.last_occurrence[o]) <= self.max_switch_time
270+
)
271+
is_switch = switch_condition
272+
######################################################################
263273
cat1 = 'SWITCH' if is_switch else 'MATCH'
264274
if cat1 == 'SWITCH':
265275
if h not in self.hypHistory:

0 commit comments

Comments
 (0)