openCV加载中文路径图片
import cv2
import numpy as np
import time
# 读取图像,解决imread不能读取中文路径的问题
def cv_imread(filePath):
cv_img=cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)
## imdecode读取的是rgb,如果后续需要opencv处理的话,需要转换成bgr,转换后图片颜色会变化
##cv_img=cv2.cvtColor(cv_img,cv2.COLOR_RGB2BGR)
return cv_img
img = cv_imread(r'E:\Python_CV\Face\images\faces1.jpg')
img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imshow("image1",img)
k=cv2.waitKey(0)