Bootstrap

Python opencv处理图像时文件名含有中文问题

都知道Python2.7版本中文显示问题,在Python3以后就没有这个问题了,但不知道为什么Python3下opencv在打开带有中文名的图片时就有问题。

测试环境:Python3.5、opencv


错误例子:

file = 'C:/测试.jpg'
import cv2
img = cv2.imread(file)
cv2.imshow('test',img)
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp, line 325
Traceback (most recent call last):
  File "<input>", line 1, in <module>
cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:325: error: (-215) size.width>0 && size.height>0 in function cv::imshow
img
print(img)
None

;