Python3 Opencv 读取图片是中文路径乱码
def cv_imread(file_path):
cvimg = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8), -1)
return cvimg
def cv_imwrite(file_path, image):
cv2.imencode('.png', image)[1].tofile(file_path)
应用 - JPG 转 PNG
from PIL import Image
root = "D:\\study\\project\\python\\技巧\\Jpg转Png\\"
img = Image.open(root + '1.jpg')
img.save(root + '1.png')
import cv2
import np
def cv_imread(file_path):
cvimg = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8), -1)
return cvimg
def cv_imwrite(file_path, image):
cv2.imencode('.png', image)[1].tofile(file_path)
image = cv_imread(root + "2.jpg")
cv_imwrite(root + "2.png")