使用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()

posted @ 2019-07-31 18:02  李艳艳665  阅读(1828)  评论(0编辑  收藏  举报