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

2019-11-23 来源: 勿忘忧 发布在  https://www.cnblogs.com/yxw1996/p/11915471.html

用Python打开图像始终提示错误

error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:352:error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
 import cv2 as cv
 img = cv.imread('D:\BjutDeeplearning\Opencvtest\python-opencv05\\black.jpg')
 cv.imshow("img", img)
 print(img.shape)
 cv.waitKey(0)
 cv.destroyAllWindows()

三个注意:

图片放在非中文路径进行读取,

图片改为非中文名,

图片名称前用双\\。

相关文章