I use this code to read the image from Logitech C720 and save them to disk in Raspberry 3B+ Raspbian stretch.
Everything goes well when I run the script for the first time, but when I rerun the script again. It was stuck as vs.read(), and I have to cancel it by CTRL+C.
Is there anything wrong with my code?
fromimutils.videoimportVideoStreamfromimutils.videoimportFPSimportdatetimeimportimutilsimporttimeimportcv2importosos.system("mkdir record")
print("[INFO] starting video stream...")
vs=VideoStream(src=0).start()
fps=FPS().start()
i=0whilei<2000:
frame=vs.read()
ifframeisNone:
continuetimestamp=datetime.datetime.now()
cv2.imwrite("record/%d.jpg"%i, frame)
printifps.update()
i+=1fps.stop()
print("[INFO] elapsed time: {:.2f}".format(fps.elapsed()))
print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
vs.stop()
I use this code to read the image from Logitech C720 and save them to disk in Raspberry 3B+ Raspbian stretch.
Everything goes well when I run the script for the first time, but when I rerun the script again. It was stuck as vs.read(), and I have to cancel it by CTRL+C.
Is there anything wrong with my code?