import cv2 cap = cv2.VideoCapture(0) i=1 while (True): ret, frame = cap.read() cv2.imwrite('captureImg'+str(i)+'.jpg', frame) cv2.imshow('Video', frame) i+=1 if cv2.waitKey(1) == 27: break cap.release() cv2.destroyAllWindows()