使用PIL的ImageGrab模块 opcv PIL
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()