(self, im_blob, img0)
| 230 | return results |
| 231 | |
| 232 | def update(self, im_blob, img0): |
| 233 | self.frame_id += 1 |
| 234 | activated_starcks = [] |
| 235 | refind_stracks = [] |
| 236 | lost_stracks = [] |
| 237 | removed_stracks = [] |
| 238 | |
| 239 | width = img0.shape[1] |
| 240 | height = img0.shape[0] |
| 241 | inp_height = im_blob.shape[2] |
| 242 | inp_width = im_blob.shape[3] |
| 243 | c = np.array([width / 2., height / 2.], dtype=np.float32) |
| 244 | s = max(float(inp_width) / float(inp_height) * height, width) * 1.0 |
| 245 | meta = {'c': c, 's': s, |
| 246 | 'out_height': inp_height // self.opt.down_ratio, |
| 247 | 'out_width': inp_width // self.opt.down_ratio} |
| 248 | |
| 249 | ''' Step 1: Network forward, get detections & embeddings''' |
| 250 | with torch.no_grad(): |
| 251 | output = self.model(im_blob)[-1] |
| 252 | hm = output['hm'].sigmoid_() |
| 253 | wh = output['wh'] |
| 254 | id_feature = output['id'] |
| 255 | id_feature = F.normalize(id_feature, dim=1) |
| 256 | |
| 257 | reg = output['reg'] if self.opt.reg_offset else None |
| 258 | dets, inds = mot_decode(hm, wh, reg=reg, ltrb=self.opt.ltrb, K=self.opt.K) |
| 259 | id_feature = _tranpose_and_gather_feat(id_feature, inds) |
| 260 | id_feature = id_feature.squeeze(0) |
| 261 | id_feature = id_feature.cpu().numpy() |
| 262 | |
| 263 | dets = self.post_process(dets, meta) |
| 264 | dets = self.merge_outputs([dets])[1] |
| 265 | |
| 266 | remain_inds = dets[:, 4] > self.opt.conf_thres |
| 267 | inds_low = dets[:, 4] > 0.2 |
| 268 | #inds_low = dets[:, 4] > self.opt.conf_thres |
| 269 | inds_high = dets[:, 4] < self.opt.conf_thres |
| 270 | inds_second = np.logical_and(inds_low, inds_high) |
| 271 | dets_second = dets[inds_second] |
| 272 | id_feature_second = id_feature[inds_second] |
| 273 | dets = dets[remain_inds] |
| 274 | id_feature = id_feature[remain_inds] |
| 275 | |
| 276 | # vis |
| 277 | ''' |
| 278 | for i in range(0, dets.shape[0]): |
| 279 | bbox = dets[i][0:4] |
| 280 | cv2.rectangle(img0, (bbox[0], bbox[1]), |
| 281 | (bbox[2], bbox[3]), |
| 282 | (0, 255, 0), 2) |
| 283 | cv2.imshow('dets', img0) |
| 284 | cv2.waitKey(0) |
| 285 | id0 = id0-1 |
| 286 | ''' |
| 287 | |
| 288 | if len(dets) > 0: |
| 289 | '''Detections''' |
nothing calls this directly
no test coverage detected