[opencv] Error: !_img.empty() in function 'imwrite'

回覆文章
Lexaul
文章: 231
註冊時間: 2019-10-18, 14:28

[opencv] Error: !_img.empty() in function 'imwrite'

文章 Lexaul » 2022-07-05, 15:21

參考資料:https://stackoverflow.com/questions/646 ... on-imwrite

代碼: 選擇全部

cap = cv2.VideoCapture('project.avi')
if cap.isOpened():
    current_frame = 0
    while True:
        ret, frame = cap.read()
        if ret:
            name = f'frameIn/frame{current_frame}.jpg'
            print(f"Creating file... {name}")
            cv2.imwrite(name, frame)
            frames.append(name)
        current_frame += 1
    cap.release()
cv2.destroyAllWindows()
[email protected]
github.com/Lexaul

回覆文章