Opencv读取显示图像报错error: (-215:Assertion failed)

Opencv读取显示图像报错error: (-215:Assertion failed)

源代码:

import cv2

img = cv2.imread('D:\Work\study\jaffe\train\happy\KA.HA1.29.tiff')
cv2.namedWindow("Image")
cv2.imshow('Image', img)
cv2.waitKey (0)

报错:
Traceback (most recent call last):
File “D:/Work/study/study_cv.py”, line 6, in
cv2.imshow(‘Image’, img)
cv2.error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\highgui\src\window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow’

原因:
从pycharm中可以看出
Opencv读取显示图像报错error: (-215:Assertion failed)_第1张图片
这里\t被理解为转义字符

改正:

import cv2

img = cv2.imread('D:\Work\study\jaffe\\train\happy\KA.HA1.29.tiff')
cv2.namedWindow("Image")
cv2.imshow('Image', img)
cv2.waitKey (0)

你可能感兴趣的:(opencv)