美文网首页
Python中cv2.imread()函数不能读中文文件名文件

Python中cv2.imread()函数不能读中文文件名文件

作者: 湯木 | 来源:发表于2020-09-17 18:22 被阅读0次

cv2.imread读取中文文件名

image = cv2.imread(image_file)

替换为:

image = cv2.imdecode(np.fromfile(image_file, dtype=np.uint8),-1)

即可。

cv2.imwrite保存中文文件名

同样,如果要保存图像为中文文件名,则将

cv2.imwrite(image_file, image)

替换为

cv2.imencode('.jpg', image)[1].tofile(image_file)

即可。
参考链接

相关文章

网友评论

      本文标题:Python中cv2.imread()函数不能读中文文件名文件

      本文链接:https://www.haomeiwen.com/subject/kuhryktx.html