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

Method update

tutorials/jde/tracker.py:177–374  ·  view source on GitHub ↗

Processes the image frame and finds bounding box(detections). Associates the detection with corresponding tracklets and also handles lost, removed, refound and active tracklets Parameters ---------- im_blob : torch.float32 Tensor o

(self, im_blob, img0)

Source from the content-addressed store, hash-verified

175 self.kalman_filter = KalmanFilter()
176
177 def update(self, im_blob, img0):
178 """
179 Processes the image frame and finds bounding box(detections).
180
181 Associates the detection with corresponding tracklets and also handles lost, removed, refound and active tracklets
182
183 Parameters
184 ----------
185 im_blob : torch.float32
186 Tensor of shape depending upon the size of image. By default, shape of this tensor is [1, 3, 608, 1088]
187
188 img0 : ndarray
189 ndarray of shape depending on the input image sequence. By default, shape is [608, 1080, 3]
190
191 Returns
192 -------
193 output_stracks : list of Strack(instances)
194 The list contains information regarding the online_tracklets for the recieved image tensor.
195
196 """
197
198 self.frame_id += 1
199 activated_starcks = [] # for storing active tracks, for the current frame
200 refind_stracks = [] # Lost Tracks whose detections are obtained in the current frame
201 lost_stracks = [] # The tracks which are not obtained in the current frame but are not removed.(Lost for some time lesser than the threshold for removing)
202 removed_stracks = []
203
204 t1 = time.time()
205 ''' Step 1: Network forward, get detections & embeddings'''
206 with torch.no_grad():
207 pred = self.model(im_blob)
208 # pred is tensor of all the proposals (default number of proposals: 54264). Proposals have information associated with the bounding box and embeddings
209 pred = pred[pred[:, :, 4] > self.low_thresh]
210 # pred now has lesser number of proposals. Proposals rejected on basis of object confidence score
211 if len(pred) > 0:
212 dets = non_max_suppression(pred.unsqueeze(0), self.low_thresh, self.opt.nms_thres)[0].cpu()
213 # Final proposals are obtained in dets. Information of bounding box and embeddings also included
214 # Next step changes the detection scales
215 scale_coords(self.opt.img_size, dets[:, :4], img0.shape).round()
216 '''Detections is list of (x1, y1, x2, y2, object_conf, class_score, class_pred)'''
217 # class_pred is the embeddings.
218
219 dets = dets.numpy()
220 remain_inds = dets[:, 4] > self.det_thresh
221 inds_low = dets[:, 4] > self.low_thresh
222 inds_high = dets[:, 4] < self.det_thresh
223 inds_second = np.logical_and(inds_low, inds_high)
224 dets_second = dets[inds_second]
225 dets = dets[remain_inds]
226
227 detections = [STrack(STrack.tlbr_to_tlwh(tlbrs[:4]), tlbrs[4], f, 30) for
228 (tlbrs, f) in zip(dets[:, :5], dets[:, 6:])]
229 else:
230 detections = []
231 dets_second = []
232
233 t2 = time.time()
234 # print('Forward: {} s'.format(t2-t1))

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