使用opencv读取视频报错:error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow‘

读取视频并显示:

import cv2

vide = cv2.VideoCapture('video2img/test0.flv')

while True:
    ret, frame = vide.read()  # 读
    cv2.imshow("capture", frame)  # 显示
    if cv2.waitKey(100) & 0xFF == ord('q'):  #键盘按键q,退出
        break

报错:

error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow’

解决办法:
将读取视频的路径改为绝对路径。

你可能感兴趣的:(使用opencv读取视频报错:error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow‘)