matplotlib plot显示图片时,鼠标点击实现图片的上下翻页 或点击下一图
fig = plt.Figure()
sorted(imgs)
id = 0
while id < len(imgs):
img = plt.imread(imgs[id])
plt.imshow(img)
ax = plt.gca()
ax.text(0, 0 + 30, str(id) + ' '+imgInfo['file_name'], fontsize=10, color='white',
bbox={'facecolor': 'r', 'alpha': 0.5})
plt.pause(0.01)
key_press = 0
while True:
pos = plt.ginput(n=1, timeout=1000)
if len(pos) > 0:
if pos[0][0] > img.shape[1]/2:
id += 1
break
if pos[0][0] < img.shape[1]/2:
id -= 1
break
plt.cla()
cv2绘制框
img_orgin = cv2.imread(path)
h, w = img_orgin.shape[:2]
l = max(h, w)
fontScale = l/1000
thickness = max(1, l//300)
cv2.rectangle(img_orgin, (x0, y0), (x1, y1), (255, 0, 0), thickness=thickness)
dis_name = class_names[category]
cv2.putText(img_orgin, f'{clc} {confidence}', (x0, y0+l//40), cv2.FONT_HERSHEY_SIMPLEX,
fontScale=fontScale, color=(0, 255, 255),
thickness=thickness)
cv2.imwrite(save_path, img_orgin)