[英]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.