Save multiple images with OpenCV and Python

前端 未结 4 1674
再見小時候
再見小時候 2021-02-06 17:52

I\'m using OpenCV and Python to take images. However currently I can only take one picture at a time. I would like to have OpenCV to take multiple pictures. This is my current c

4条回答
  •  天涯浪人
    2021-02-06 18:30

    i think this wil helpful...

    import cv2
    
    vid = cv2.VideoCapture("video.mp4")
    d = 0
    ret, frame = vid.read()
    
    while ret:
        ret, frame = vid.read()
        filename = "images/file_%d.jpg"%d
        cv2.imwrite(filename, frame)
        d+=1
    

    this will save every frame with different name.

提交回复
热议问题