【已解决】error: (-215) size.width>0 && size.height>0 in function imshow

关于使用Python和OpenCV处理图像报error:(-215)错误的解决方法

import cv2
image = cv2.imread("./image/jurassic-park-tour-jeep.jpg")
cv2.imshow("original",image)
cv2.waitKey(0)

毕业论文搞模式识别和计算机视觉方法的研究内容,初次处理图像就遇到如下的错误:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/buildd/opencv-2.4.9+dfsg/modules/highgui/src/window.cpp, line 269
Traceback (most recent call last):
  File "/media/april/Files/ubuntuProject/.vscode/ImageProcessing/BasicImageManipulations.py", line 9, in 
    cv2.imshow("original",image)
cv2.error: /build/buildd/opencv-2.4.9+dfsg/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow

刚开始怀疑是Python3.4版本问题,于是毫不犹豫地切换到Python2.7版本。但是,问题依旧出现,肯定了不是版本的问题。于是检查图像路径,用绝对路径替换后问题解决了。

image = cv2.imread("/media/april/Files/ubuntuProject/.vscode/ImageProcessing/images/jurassic-park-tour-jeep.jpg")

你可能感兴趣的:(Python,OpenCV)