Follow the following steps to extract images from video. Here all extracted images will be saved in the current folder.
# Extraction of images from Video
import cv2
# Opens the Video file
cap= cv2.VideoCapture('canny.mp4')
i=0
while(cap.isOpened()):
ret, frame = cap.read()
if ret == False:
break
cv2.imwrite('kang'+str(i)+'.jpg',frame)
i+=1
cap.release()
cv2.destroyAllWindows()
After running above code, all the the image from video will be stored in current folder.
Note: for above program, create new folder and save above program file in that folder then run your program. your folder will be full of images after running above code.