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

Method step

tutorials/trades/byte_tracker.py:179–311  ·  view source on GitHub ↗
(self, results, public_det=None)

Source from the content-addressed store, hash-verified

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
205 (tlbr, s) in zip(dets, scores_keep)]
206 else:
207 detections = []
208
209 ''' Add newly detected tracklets to tracked_stracks'''
210 unconfirmed = []
211 tracked_stracks = [] # type: list[STrack]
212 for track in self.tracked_stracks:
213 if not track.is_activated:
214 unconfirmed.append(track)
215 else:
216 tracked_stracks.append(track)
217
218 ''' Step 2: First association, with Kalman and IOU'''
219 strack_pool = joint_stracks(tracked_stracks, self.lost_stracks)
220 # Predict the current location with KF
221 STrack.multi_predict(strack_pool)
222 dists = matching.iou_distance(strack_pool, detections)
223 #dists = matching.fuse_motion(self.kalman_filter, dists, strack_pool, detections)
224 matches, u_track, u_detection = matching.linear_assignment(dists, thresh=0.9)
225
226 for itracked, idet in matches:
227 track = strack_pool[itracked]
228 det = detections[idet]
229 if track.state == TrackState.Tracked:
230 track.update(detections[idet], self.frame_id)
231 activated_starcks.append(track)
232 else:
233 track.re_activate(det, self.frame_id, new_id=False)
234 refind_stracks.append(track)
235
236 ''' Step 3: Second association, association the untrack to the low score detections, with IOU'''

Callers

nothing calls this directly

Calls 11

STrackClass · 0.70
joint_stracksFunction · 0.70
sub_stracksFunction · 0.70
remove_duplicate_stracksFunction · 0.70
tlbr_to_tlwhMethod · 0.45
multi_predictMethod · 0.45
updateMethod · 0.45
re_activateMethod · 0.45
mark_lostMethod · 0.45
mark_removedMethod · 0.45
activateMethod · 0.45

Tested by

no test coverage detected