1、中文字符文件名处理
读、写文件:
image = cv2.imread('xxx.jpg')
cv2.imwrite('xxx.jpg', image)
如果文件名或路径含中文,则:
image = cv2.imdecode(np.fromfile(‘xxx.jpg’, dtype=np.uint8), -1)
cv2.imencode('.jpg', image)[1].tofile(file_name)
2、彩色图转换为灰度图
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)