使用PIL的ImageGrab模块


import time
from PIL import ImageGrab
import numpy as np
import cv2

beg = time.time()
debug = False
# img = ImageGrab.grab(bbox=(250, 161, 1141, 610))
img = ImageGrab.grab()
end = time.time()
print('time:',end - beg)

img.show()
img.save("screen.jpg")

# PIL image to OpenCV image
im = np.array(img)
cv2.imshow('cv image', im)
cv2.waitKey(http://www.my516.com/heimitao/)

# OpenCV image to PIL image
im_pil = PIL.Image.fromarray(im)
im_pil.show()


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM