'how to train this code of extracting frames from video

import cv2
import os

vid = cv2.VideoCapture("D:\Huawei Share\Backup/vid1.mp4")
currentframe = 0

if not os.path.exists("data"):
    os.makedirs("data")

while (True):
    success, frame = vid.read()

    cv2.imshow("output", frame)
    cv2.imwrite("./data/frame" + str(currentframe) + ".jpg", frame)
    currentframe += 1

    if cv2.waitKey(1) & 0xFF == ord("q"):
        break
webCam.release()
cv2.destroyAllWindows()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source