Python中如何使用OpenCV读取中文名称的图像

可以自定义两个函数,分别为imread和imwrite

 

def imread(image_path, flags=cv2.IMREAD_COLOR):
        original_image = cv2.imdecode(
            np.fromfile(image_path, dtype=np.uint8), flags)
        return original_image

 

def imwrite(original_image, image_path, ext='.jpg', compress_rate=[int(cv2.IMWRITE_JPEG_QUALITY), 100]):
        cv2.imencode(ext, original_image, compress_rate)[1].tofile(image_path)

你可能感兴趣的:(Python中如何使用OpenCV读取中文名称的图像)