MCPcopy Index your code
hub / github.com/FoundationVision/ByteTrack / update

Method update

yolox/tracker/byte_tracker.py:159–289  ·  view source on GitHub ↗
(self, output_results, img_info, img_size)

Source from the content-addressed store, hash-verified

157 self.kalman_filter = KalmanFilter()
158
159 def update(self, output_results, img_info, img_size):
160 self.frame_id += 1
161 activated_starcks = []
162 refind_stracks = []
163 lost_stracks = []
164 removed_stracks = []
165
166 if output_results.shape[1] == 5:
167 scores = output_results[:, 4]
168 bboxes = output_results[:, :4]
169 else:
170 output_results = output_results.cpu().numpy()
171 scores = output_results[:, 4] * output_results[:, 5]
172 bboxes = output_results[:, :4] # x1y1x2y2
173 img_h, img_w = img_info[0], img_info[1]
174 scale = min(img_size[0] / float(img_h), img_size[1] / float(img_w))
175 bboxes /= scale
176
177 remain_inds = scores > self.args.track_thresh
178 inds_low = scores > 0.1
179 inds_high = scores < self.args.track_thresh
180
181 inds_second = np.logical_and(inds_low, inds_high)
182 dets_second = bboxes[inds_second]
183 dets = bboxes[remain_inds]
184 scores_keep = scores[remain_inds]
185 scores_second = scores[inds_second]
186
187 if len(dets) > 0:
188 '''Detections'''
189 detections = [STrack(STrack.tlbr_to_tlwh(tlbr), s) for
190 (tlbr, s) in zip(dets, scores_keep)]
191 else:
192 detections = []
193
194 ''' Add newly detected tracklets to tracked_stracks'''
195 unconfirmed = []
196 tracked_stracks = [] # type: list[STrack]
197 for track in self.tracked_stracks:
198 if not track.is_activated:
199 unconfirmed.append(track)
200 else:
201 tracked_stracks.append(track)
202
203 ''' Step 2: First association, with high score detection boxes'''
204 strack_pool = joint_stracks(tracked_stracks, self.lost_stracks)
205 # Predict the current location with KF
206 STrack.multi_predict(strack_pool)
207 dists = matching.iou_distance(strack_pool, detections)
208 if not self.args.mot20:
209 dists = matching.fuse_score(dists, detections)
210 matches, u_track, u_detection = matching.linear_assignment(dists, thresh=self.args.match_thresh)
211
212 for itracked, idet in matches:
213 track = strack_pool[itracked]
214 det = detections[idet]
215 if track.state == TrackState.Tracked:
216 track.update(detections[idet], self.frame_id)

Callers 2

imageflow_demoFunction · 0.95
evaluateMethod · 0.95

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