1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import numpy as np
- from collections import OrderedDict
- class TrackState(object):
- New = 0
- Tracked = 1
- Lost = 2
- Removed = 3
- class BaseTrack(object):
- def __init__(self, tracker_max_id):
- self.tracker_max_id = tracker_max_id
- _count = 0
- track_id = 0
- is_activated = False
- state = TrackState.New
- history = OrderedDict()
- features = []
- curr_feature = None
- score = 0
- start_frame = 0
- frame_id = 0
- time_since_update = 0
- # multi-camera
- location = (np.inf, np.inf)
- @property
- def end_frame(self):
- return self.frame_id
- def next_id(self):
- if BaseTrack._count == self.tracker_max_id:
- BaseTrack._count = 0
- BaseTrack._count += 1
- return BaseTrack._count
- def activate(self, *args):
- raise NotImplementedError
- def predict(self):
- raise NotImplementedError
- def update(self, *args, **kwargs):
- raise NotImplementedError
- def mark_lost(self):
- self.state = TrackState.Lost
- def mark_removed(self):
- self.state = TrackState.Removed
|