此代码正在运行,但是需要四秒钟(或四张图片)来检测运动。
图片为640px x 480px。
联想T520,ELP摄像头-1920 x 1080-ELP Svpro 5-50mm,python3。
我用 cap = VideoStream(src = 1).start()尝试了相同的代码,并且运行完美。
对我来说是个谜
为什么cap = cv2.VideoCapture(1)这么慢?
ps:故意在图片之间等待一秒钟的时间
import cv2
#could be 0 for laptop camera, 1 for second camera
cap = cv2.VideoCapture(1)
count = 0
while True:
_, frame = cap.read()
cv2.imshow("Frame", frame)
key = cv2.waitKey(1000)
print(count)
count +=1
#27 is escape key
if key == 27:
break
cap.release()
cv2.destroyAllWindows()