问题描述

cv2.imread路径为中文时返回None。

方案

python3 opencv中文路径图片读取和写入

读取(先用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

相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2021-06-27
  • 2022-02-09
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
猜你喜欢
  • 2022-02-09
  • 2022-02-09
  • 2022-12-23
  • 2022-02-09
  • 2022-02-09
  • 2021-06-30
  • 2021-12-01
相关资源
相似解决方案