美文网首页
python中OpenCV读取中文路径的图片

python中OpenCV读取中文路径的图片

作者: 卡拉肖克_潘 | 来源:发表于2020-01-28 10:32 被阅读0次

参考:opencv_python使用cv2.imread()读取中文路径报错问题

def cv_imread(filePath):
    cv_img=cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)
    return cv_img

if __name__=='__main__':

    path='E:/images/百合/百合1.jpg'

    img=cv_imread(path)

    cv2.namedWindow('lena',cv2.WINDOW_AUTOSIZE)

    cv2.imshow('lena',img)

    k=cv2.waitKey(0)

    ##这样是保存到了和当前运行目录下

    cv2.imencode('.jpg', img)[1].tofile('百合.jpg')

相关文章

网友评论

      本文标题:python中OpenCV读取中文路径的图片

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