(python走过的坑)OpenCV中错误opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow

第一次在python中使用OpenCV(cv2),运行时报错opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow

源码如下:

import cv2
img = cv2.imread('路.jpg')
cv2.namedWindow("w")
cv2.imshow('w',img)
cv2.waitKey(0)

路径中文件如下:

(python走过的坑)OpenCV中错误opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow

运行报错:

cv2.error: D:\Build\OpenCV\opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow

解决:

百度一下,上面说有可能是路径问题,明显我这个不是,因为使用的是相对路径,

后来把文件名改成英文就好了:路.jpg --> lu.jpg

import cv2
img = cv2.imread('lu.jpg')
cv2.namedWindow("w")
cv2.imshow('w',img)
cv2.waitKey(0)

文件改成:

(python走过的坑)OpenCV中错误opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow

上一篇:IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005


下一篇:window.onload、DOMContentLoaded和$(document).ready()