python matplotlib绘图

记录常用的python matplotlib的一些操作

1.循环画图的时候每次记得plt.close() 不然会在一张图上反复画

2.不要先plt.show()再存储,每次show完plt就会默认清空,存储的就是一片空白
3.目标检测中画出检测框

bbox_int = bbox.astype(np.float).astype(np.int32)
left_top = (bbox_int[0], bbox_int[1])
right_bottom = (bbox_int[2], bbox_int[3])
#几种推荐的颜色red:(100, 100, 255); blue:(255, 100, 100); green:(100, 255, 100); magenta:(255, 100, 255)
cv2.rectangle(img, left_top, right_bottom, (255, 100, 100), thickness=thickness) #blue
label_text = self.CLASSES[label - 1] if self.CLASSES is not None else 'cls {}'.format(label-1)
label_text += '|{:.02f}'.format(float(box_socre))
(text_width, text_height) = cv2.getTextSize(label_text, cv2.FONT_HERSHEY_COMPLEX, fontScale=font_scale,thickness=text_thickness)[0]
box_coords = ((bbox_int[0], bbox_int[1] - 2), (bbox_int[0] + text_width - 2, bbox_int[1] - text_height - 2))
cv2.rectangle(img, box_coords[0], box_coords[1], (255, 100, 100), cv2.FILLED)
cv2.putText(img, label_text, (bbox_int[0], bbox_int[1] - 2),
           cv2.FONT_HERSHEY_COMPLEX, font_scale, (255, 255, 255), thickness=text_thickness)

效果图
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值