From eb486baa2642fee01eacf555a5e6e1b504b136a3 Mon Sep 17 00:00:00 2001 From: Sufiyan Adhikari Date: Sun, 8 May 2022 23:55:33 +0530 Subject: [PATCH] Change BaseTrack attributes to Object attributes All the attributes are used after object initialisation only, so there is no reason to keep them as Class attributes. Keeping them as class attributes instead causes #79 This should fix #79 and should not affect any other part. Have checked that we always call `self.next_id()` and never call `BaseTrack.next_id()` i.e., no need for it to be a static method anymore, since all the attributes are now object attributes. --- yolox/tracker/basetrack.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/yolox/tracker/basetrack.py b/yolox/tracker/basetrack.py index a7130b5c..d5837b05 100644 --- a/yolox/tracker/basetrack.py +++ b/yolox/tracker/basetrack.py @@ -10,31 +10,31 @@ class TrackState(object): class BaseTrack(object): - _count = 0 + def __init__(self): + self._count = 0 - track_id = 0 - is_activated = False - state = TrackState.New + self.track_id = 0 + self.is_activated = False + self.state = TrackState.New - history = OrderedDict() - features = [] - curr_feature = None - score = 0 - start_frame = 0 - frame_id = 0 - time_since_update = 0 + self.history = OrderedDict() + self.features = [] + self.curr_feature = None + self.score = 0 + self.start_frame = 0 + self.frame_id = 0 + self.time_since_update = 0 - # multi-camera - location = (np.inf, np.inf) + # multi-camera + self.location = (np.inf, np.inf) @property def end_frame(self): return self.frame_id - @staticmethod - def next_id(): - BaseTrack._count += 1 - return BaseTrack._count + def next_id(self): + self._count += 1 + return self._count def activate(self, *args): raise NotImplementedError @@ -49,4 +49,4 @@ def mark_lost(self): self.state = TrackState.Lost def mark_removed(self): - self.state = TrackState.Removed \ No newline at end of file + self.state = TrackState.Removed