图像base64和opencv格式的互相转换

 opencv转换base64

image = cv2.imencode('.jpg', frame)[1]
imgbase64 = str(base64.b64encode(image))[2:-1]

 base64转换opencv

img_b64decode = base64.b64decode(base64data)  # base64解码
img_array = np.frombuffer(img_b64decode, np.uint8)  # 转换np序列
img = cv2.imdecode(img_array, cv2.COLOR_BGR2RGB)  # 转换Opencv格式

你可能感兴趣的:(Python,base64,opencv,python)