7 for i
in six.moves.range(nlabels):
17 colors.append([r, g, b])
24 font_face=cv2.FONT_HERSHEY_SIMPLEX,
25 text_color=(255, 255, 255),
27 """Visualize bounding boxes inside image. 30 if len(bboxes) != len(labels):
31 raise ValueError(
"len(bboxes) and len(labels) should be same " 32 "we get len(bboxes):{}, len(lables):{}" 33 .format(len(bboxes), len(labels)))
37 for bbox, label
in zip(bboxes, labels):
38 color = colormap[label % max_label_num]
42 x1, y1, x2, y2 = map(int, [x1, y1, x2, y2])
43 cv2.rectangle(img, (x1, y1), (x2, y2), color, 2, CV_AA)
45 label_name = str(label)
46 img_bbox = img[y1:y2, x1:]
49 size, baseline = cv2.getTextSize(
50 text, font_face, font_scale, thickness)
52 img_bbox, (0, 0), (size[0], size[1] + baseline),
53 color=color, thickness=-1)
54 cv2.putText(img_bbox, text, (0, size[1]),
55 font_face, font_scale, text_color, thickness)
def vis_bboxes(img, bboxes, labels, font_scale=0.8, thickness=1, font_face=cv2.FONT_HERSHEY_SIMPLEX, text_color=(255, 255, 255), max_label_num=1024)
def voc_colormap(nlabels)