解决:报错cv2.error: OpenCV(4.1.2) error: (-215:Assertion failed) _img.empty() in function ‘cv::imwrite

 

frame = cv2.resize(frame, (960, 540))
 
  

 

百度查看一篇博客这样写

解决:报错cv2.error: OpenCV(4.1.2) error: (-215:Assertion failed) _img.empty() in function ‘cv::imwrite_第1张图片

 都检查一篇发现没问题,折腾了半天,才明白视频取到最后一帧了,frame为None,

只需要加上一行代码即可:

        if frame is None:
            break
        else:
            frame = cv2.resize(frame, (960, 540))

你可能感兴趣的:(opencv,python,c语言)