【Opencv】打开含有中文路径图片
- # 读取图像,解决imread不能读取中文路径的问题
- def CvImread(filePath):
- # 核心就是下面这句,一般直接用这句就行,直接把图片转为mat数据
- cvImg = cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)
- return cvImg
-
- # 读取图像,解决imread不能读取中文路径的问题
- # cv2.IMWRITE_PNG_COMPRESSION, 从0到9 压缩级别越高图像越小。
- def CvImwrite(image, savePath):
- # 核心就是下面这句,一般直接用这句就行,直接把图片转为mat数据
- cv2.imencode('.png', image, [int(cv2.IMWRITE_PNG_COMPRESSION), 1])[1].tofile(savePath)