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

Class BYTETracker

tutorials/centertrack/byte_tracker.py:146–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected