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

 

用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'
1 import cv2 as cv
2 img = cv.imread('D:\BjutDeeplearning\Opencvtest\python-opencv05\\black.jpg')
3 cv.imshow("img", img)
4 print(img.shape)
5 cv.waitKey(0)
6 cv.destroyAllWindows()

三个注意:

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

图片改为非中文名,

图片名称前用双\\。

 

上一篇:LeetCode-Heap-215-M: 数组中的第K个最大元素


下一篇:解决OpenCV error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::im