赞
踩
1.在general.py,导入
from PIL import Image, ImageDraw, ImageFont
2.找到plot_one_labels
把 if label改为以下
- tf = max(tl - 1, 1) # font thickness
- t_size = cv2.getTextSize(label, 0, fontScale=tl / 3, thickness=tf)[0]
- font_size = t_size[1]
- font = ImageFont.truetype('msyh.ttc', font_size)
- t_size = font.getsize(label)
- c2 = c1[0] + t_size[0], c1[1] - t_size[1]
- cv2.rectangle(img, c1, c2, color, -1, cv2.LINE_AA) # filled
- img_PIL = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
- draw = ImageDraw.Draw(img_PIL)
- draw.text((c1[0], c2[1] - 2), label, fill=(255, 255, 255), font=font)
- return cv2.cvtColor(np.array(img_PIL), cv2.COLOR_RGB2BGR)
3.找到plot_images
plot_one_box(box, mosaic, label=label, color=color, line_thickness=tl)
改为
mosaic = plot_one_box(box, mosaic, label=label, color=color, line_thickness=tl)
4.在detect.py中
plot_one_box(xyxy, im0, label=label, color=colors(c, True), line_thickness=3)
改为
im0 = plot_one_box(xyxy, im0, label=label, color=colors(c, True), line_thickness=3)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。