问题描述
cv2.imread路径为中文时返回None。
方案
读取(先用np.fromfile读取为np.uint8格式,再使用cv2.imdecode解码):
# 文件路径file_path,返回读取后的图片
cv_img = cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),-1)
写入:
cv2.imencode('.jpg',img)[1].tofile(file_path)
参考:https://www.zhihu.com/question/47184512