当我运行下面的代码时,它会打开一个具有适当尺寸的新窗口,并正确地显示屏幕……但是它会不断地在顶部和内部打开新的窗口。在
import numpy as np
from PIL import ImageGrab
import cv2
while(True):
printscreen_pil = ImageGrab.grab(bbox = (0, 40, 400, 340))
printscreen_numpy = np.array(printscreen_pil.getdata(), dtype =
'uint8').reshape((printscreen_pil.size[1], printscreen_pil.size[0], 3))
cv2.imshow('window', printscreen_numpy)
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
系统为windows 10,64位 python 3.6
你需要在while之前创建一个namedWindow。并使用名称(第一个参数)显示图像,它将始终在同一个窗口中显示图像。在
相关问题 更多 >
编程相关推荐