buildOpenCVXavier
buildOpenCVXavier copied to clipboard
Webcam capture using OpenCV only capturing one frame
I've written the following code:
import cv2
import numpy as np
import time
print("Starting...")
time.sleep(1)
c = cv2.VideoCapture(0)
while(1):
print("Capturing...")
didItWork,f = c.read()
print(didItWork)
cv2.imwrite("output.jpg", f)
cv2.destroyAllWindows()
The first frame is captured correctly and stored as output.jpg, however after that it hangs on the c.read()
code.
I can't even cancel the program by pressing CTRL + C
. Only if I unplug the webcam afterwards it seems to exit:
(I pressed CTRL + C after the second
Capturing...
, after that I unplugged the webcam and then the messages came regarding traceback....
)
I'm not really sure where to start so I was hoping you might have an idea?