def draw_boxes(im, dets, classes, scale = 1.0):
color_white = (255, 255, 255)
for cls_idx, cls_name in enumerate(classes):
cls_dets = dets[cls_idx]
for det in cls_dets:
bbox = det[:4] * scale
bbox = map(int, bbox)
color = (random.randint(0, 256), random.randint(0, 256), random.randint(0, 256))
cv2.rectangle(im, (bbox[0], bbox[1]), (bbox[2], bbox[3]), color=color, thickness=3)
if cls_dets.shape[1] == 5:
score = det[-1]
cv2.putText(im, '%s %.3f' % (cls_name, score), (bbox[0], bbox[1]+10),
color=color_white, fontFace=cv2.FONT_HERSHEY_COMPLEX, fontScale=1, thickness=2)
return im
show_boxes.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录