我得到了使用枕头ImageGrab在python中记录屏幕的代码,该图像在我的python 3.5版本中无法正常工作。视频帧的大小不断减小。
import numpy as np
from PIL import ImageGrab
import cv2
import time
last_time = time.time()
while(True):
# 800x600 windowed mode
printscreen = np.array(ImageGrab.grab(bbox=(0,0,800,600)))
print('loop took {} seconds'.format(time.time()-last_time))
last_time = time.time()
cv2.imshow('window',cv2.cvtColor(printscreen, cv2.COLOR_BGR2RGB))
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
慕沐林林
相关分类