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

Method step

tutorials/centertrack/byte_tracker.py:178–309  ·  view source on GitHub ↗
(self, results, public_det=None)

Source from the content-addressed store, hash-verified

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