[英]the fastest method of capturing full screen with python?
我使用的是 PIL 的 ImageGrab,但這對於項目來說太慢了。
有沒有不使用 PIL 的替代方案?
捕獲圖像相當於捕獲視頻的單幀。 您可以使用 OpenCV 的 VideoCapture 方法來完成。
import cv2
cap = cv2.VideoCapture(0) # video capture source camera (Here webcam of laptop)
ret,frame = cap.read() # return a single frame in variable `frame`
while(True):
cv2.imshow('img',frame) #display the captured image
if cv2.waitKey(1) & 0xFF == ord('y'): #save on pressing 'y'
cv2.imwrite('images/test.png',frame)
cv2.destroyAllWindows()
break
cap.release()
查看OpenCV教程了解更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.