Skip to content

Commit

Permalink
Change BaseTrack attributes to Object attributes
Browse files Browse the repository at this point in the history
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 ifzhang#79 

This should fix ifzhang#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.
  • Loading branch information
dumbPy authored May 8, 2022
1 parent 2c082be commit eb486ba
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions yolox/tracker/basetrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,4 +49,4 @@ def mark_lost(self):
self.state = TrackState.Lost

def mark_removed(self):
self.state = TrackState.Removed
self.state = TrackState.Removed

0 comments on commit eb486ba

Please sign in to comment.