| 163 | |
| 164 | |
| 165 | class BYTETracker(object): |
| 166 | def __init__(self, frame_rate=30): |
| 167 | self.tracked_stracks = [] # type: list[STrack] |
| 168 | self.lost_stracks = [] # type: list[STrack] |
| 169 | self.removed_stracks = [] # type: list[STrack] |
| 170 | |
| 171 | self.frame_id = 0 |
| 172 | |
| 173 | self.low_thresh = 0.2 |
| 174 | self.track_thresh = 0.8 |
| 175 | self.det_thresh = self.track_thresh + 0.1 |
| 176 | |
| 177 | |
| 178 | self.buffer_size = int(frame_rate / 30.0 * 30) |
| 179 | self.max_time_lost = self.buffer_size |
| 180 | self.kalman_filter = KalmanFilter() |
| 181 | |
| 182 | # def update(self, output_results): |
| 183 | def update(self, det_bboxes, det_labels, frame_id, track_feats): |
| 184 | |
| 185 | # self.frame_id += 1 |
| 186 | self.frame_id = frame_id + 1 |
| 187 | activated_starcks = [] |
| 188 | refind_stracks = [] |
| 189 | lost_stracks = [] |
| 190 | removed_stracks = [] |
| 191 | |
| 192 | # scores = output_results[:, 4] |
| 193 | # bboxes = output_results[:, :4] # x1y1x2y2 |
| 194 | scores = det_bboxes[:, 4].cpu().numpy() |
| 195 | bboxes = det_bboxes[:, :4].cpu().numpy() |
| 196 | |
| 197 | track_feature = F.normalize(track_feats).cpu().numpy() |
| 198 | |
| 199 | remain_inds = scores > self.track_thresh |
| 200 | dets = bboxes[remain_inds] |
| 201 | scores_keep = scores[remain_inds] |
| 202 | id_feature = track_feature[remain_inds] |
| 203 | |
| 204 | |
| 205 | inds_low = scores > self.low_thresh |
| 206 | inds_high = scores < self.track_thresh |
| 207 | inds_second = np.logical_and(inds_low, inds_high) |
| 208 | dets_second = bboxes[inds_second] |
| 209 | scores_second = scores[inds_second] |
| 210 | id_feature_second = track_feature[inds_second] |
| 211 | |
| 212 | if len(dets) > 0: |
| 213 | '''Detections''' |
| 214 | detections = [STrack(STrack.tlbr_to_tlwh(tlbr), s, f) for |
| 215 | (tlbr, s, f) in zip(dets, scores_keep, id_feature)] |
| 216 | else: |
| 217 | detections = [] |
| 218 | |
| 219 | |
| 220 | ''' Add newly detected tracklets to tracked_stracks''' |
| 221 | unconfirmed = [] |
| 222 | tracked_stracks = [] # type: list[STrack] |
nothing calls this directly
no outgoing calls
no test coverage detected