Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
import cv2
from time import sleep 

# Set the time delay between frames
delay = 2.5

#select folder to write to
folder = ''

cap = cv2.VideoCapture(0)

#set the width and height
cap.set(4, 1280)
cap.set(3, 1024)

ret, frame = cap.read()
count = 0
while True:
    ret, frame = cap.read()
    frame_num = "%08d" % (count)
    cv2.imwrite(folder + frame_num + '.jpg', frame)
    k = cv2.waitKey(1)
    count += 1
    sleep(delay)

cap.release()
cv2.destroyAllWindows()