imread参数路径问题

错误提示

Traceback (most recent call last):
  File "C:\Users\Jason\Documents\workspace\Day20190103\test02\ReadPct.py", line 11, in <module>
    cv2.imshow('image',image)
cv2.error: OpenCV(3.4.5) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:358: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

解决方式

不能正确读取imread中的图像,需要检查imread读取的路径或者将

imread(文件路径)文件路径改为绝对路径,python中路径分隔府只支持“\\”和“/”。

如果填入绝对路径,当前路径是指程序所在的路径,如果该程序文件在包下,先“../”返回上一层目录,比如是项目路径,再进入指定的图片路径

猜你喜欢

转载自www.cnblogs.com/smartmsl/p/10217370.html