MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / BYTETracker

Class BYTETracker

tutorials/trades/byte_tracker.py:147–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145
146
147class BYTETracker(object):
148 def __init__(self, args, frame_rate=30):
149 self.args = args
150 self.det_thresh = args.new_thresh
151 self.buffer_size = int(frame_rate / 30.0 * args.track_buffer)
152 self.max_time_lost = self.buffer_size
153 self.reset()
154
155 # below has no effect to final output, just to be compatible to codebase
156 def init_track(self, results):
157 for item in results:
158 if item['score'] > self.opt.new_thresh and item['class'] == 1:
159 self.id_count += 1
160 item['active'] = 1
161 item['age'] = 1
162 item['tracking_id'] = self.id_count
163 if not ('ct' in item):
164 bbox = item['bbox']
165 item['ct'] = [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2]
166 self.tracks.append(item)
167
168 def reset(self):
169 self.frame_id = 0
170 self.kalman_filter = KalmanFilter()
171 self.tracked_stracks = [] # type: list[STrack]
172 self.lost_stracks = [] # type: list[STrack]
173 self.removed_stracks = [] # type: list[STrack]
174 self.tracks = []
175
176 # below has no effect to final output, just to be compatible to codebase
177 self.id_count = 0
178
179 def step(self, results, public_det=None):
180 self.frame_id += 1
181 activated_starcks = []
182 refind_stracks = []
183 lost_stracks = []
184 removed_stracks = []
185 detections = []
186 detections_second = []
187
188 scores = np.array([item['score'] for item in results if item['class'] == 1], np.float32)
189 bboxes = np.vstack([item['bbox'] for item in results if item['class'] == 1]) # N x 4, x1y1x2y2
190
191 remain_inds = scores >= self.args.track_thresh
192 dets = bboxes[remain_inds]
193 scores_keep = scores[remain_inds]
194
195
196 inds_low = scores > self.args.out_thresh
197 inds_high = scores < self.args.track_thresh
198 inds_second = np.logical_and(inds_low, inds_high)
199 dets_second = bboxes[inds_second]
200 scores_second = scores[inds_second]
201
202 if len(dets) > 0:
203 '''Detections'''
204 detections = [STrack(STrack.tlbr_to_tlwh(tlbr), s) for

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected