(ori_img, bbox, identities=None, offset=(0, 0), cvt_color=False)
| 95 | |
| 96 | |
| 97 | def draw_bboxes(ori_img, bbox, identities=None, offset=(0, 0), cvt_color=False): |
| 98 | if cvt_color: |
| 99 | ori_img = cv2.cvtColor(np.asarray(ori_img), cv2.COLOR_RGB2BGR) |
| 100 | img = ori_img |
| 101 | for i, box in enumerate(bbox): |
| 102 | x1, y1, x2, y2 = [int(i) for i in box[:4]] |
| 103 | x1 += offset[0] |
| 104 | x2 += offset[0] |
| 105 | y1 += offset[1] |
| 106 | y2 += offset[1] |
| 107 | if len(box) > 4: |
| 108 | score = '{:.2f}'.format(box[4]) |
| 109 | else: |
| 110 | score = None |
| 111 | # box text and bar |
| 112 | id = int(identities[i]) if identities is not None else 0 |
| 113 | color = COLORS_10[id % len(COLORS_10)] |
| 114 | label = '{:d}'.format(id) |
| 115 | # t_size = cv2.getTextSize(label, cv2.FONT_HERSHEY_PLAIN, 2 , 2)[0] |
| 116 | img = plot_one_box([x1, y1, x2, y2], img, color, label, score=score) |
| 117 | return img |
| 118 | |
| 119 | |
| 120 | def draw_points(img: np.ndarray, points: np.ndarray, color=(255, 255, 255)) -> np.ndarray: |
no test coverage detected