| 214 | return dets[0] |
| 215 | |
| 216 | def merge_outputs(self, detections): |
| 217 | results = {} |
| 218 | for j in range(1, self.opt.num_classes + 1): |
| 219 | results[j] = np.concatenate( |
| 220 | [detection[j] for detection in detections], axis=0).astype(np.float32) |
| 221 | |
| 222 | scores = np.hstack( |
| 223 | [results[j][:, 4] for j in range(1, self.opt.num_classes + 1)]) |
| 224 | if len(scores) > self.max_per_image: |
| 225 | kth = len(scores) - self.max_per_image |
| 226 | thresh = np.partition(scores, kth)[kth] |
| 227 | for j in range(1, self.opt.num_classes + 1): |
| 228 | keep_inds = (results[j][:, 4] >= thresh) |
| 229 | results[j] = results[j][keep_inds] |
| 230 | return results |
| 231 | |
| 232 | def update(self, im_blob, img0): |
| 233 | self.frame_id += 1 |