opencv中cv2.imread()中文路径 AttributeError: ‘NoneType‘ object has no attribute ‘shape‘
报错:AttributeError: ‘NoneType’ object has no attribute ‘shape’
问题描述:当使用cv2.imread读取图片路径包含中文时,会造成无法读入图片,而又不报错,其实什么都没有读入。
原因:因为python 3.x 将系统字符编码默认为了Unicode,而opencv 读取图片函数的输入参数默认用gbk格式处理。
解决:
使用imdecode读入
# 使用imdecode读入
img = cv2.imdecode(np.fromfile("./a/000
转载
2022-05-25 11:38:09 ·
501 阅读 ·
0 评论