1 回答

TA貢獻(xiàn)1776條經(jīng)驗 獲得超12個贊
您可以使用mss
“純 python 中的超快速跨平臺多個屏幕截圖模塊”。
例如:
import time
import cv2
import numpy as np
from mss import mss
start_time = time.time()
mon = {'top': 200, 'left': 200, 'width': 200, 'height': 200}
with mss() as sct:
? ? while True:
? ? ? ? last_time = time.time()
? ? ? ? img = sct.grab(mon)
? ? ? ? print('The loop took: {0}'.format(time.time()-last_time))
? ? ? ? cv2.imshow('test', np.array(img))
? ? ? ? if cv2.waitKey(25) & 0xFF == ord('q'):
? ? ? ? ? ? cv2.destroyAllWindows()
? ? ? ? ? ? break
結(jié)果:
The loop took: 0.024120092391967773
輸出:
結(jié)果比當(dāng)前結(jié)果快 100 倍。
添加回答
舉報