(1)错误代码

import cv2 as cv

src = cv.imread("D:\images\我喜欢的发型\07.PNG")
cv.namedWindow("Hello", cv.WINDOW_AUTOSIZE)
cv.imshow("Hello", src)
cv.waitKey(0)
cv.destoryAllWindows()

(2)错误描述

D:\DevKits\Anaconda3\python.exe D:/workspace/pycharm/OpenCVNotes/Lesson1.py
Traceback (most recent call last):
  File "D:/workspace/pycharm/OpenCVNotes/Lesson1.py", line 9, in 
    cv.imshow("Hello", src)
cv2.error: OpenCV(4.0.0) d:\build\opencv\opencv-4.0.0\modules\highgui\src\window.cpp:358: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

Process finished with exit code 1

(3)错误原因

cv2.imread()函数的filename参数不接受带有中文的路径.

(4)正确代码

import cv2 as cv

src = cv.imread("D:\images\me.png")
cv.namedWindow("Hello", cv.WINDOW_AUTOSIZE)
cv.imshow("Hello", src)
cv.waitKey(0)
cv.destoryAllWindows()