I am trying to get a frame from the camera every each 3 seconds using cv2.VideoCapture()
so I used time.sleep()
to pause the execution, the code is here:
import cv2
import time
cnt = 0
cap = cv2.VideoCapture(0)
while (True):
time.sleep(3)
ret, frame = cap.read()
cv2.imwrite('{}.png'.format(cnt),frame)
cnt+=1
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
And I got a stopwatch in front on the camera and save a frame each 3 seconds but I found that after the first frame there are other 4 frames that are wrongly saved so the saved images time is: 1.0, 1.1, 1.1, 1.2, 1.3, 2, 3, 4, 5, 6, etc. Then how on earth that's happening?