python ndarray 与 base64 互转 接口传递ndarry
python ndarray 与 base64 互转 post接口传递ndarry1.ndarray转base64print(ndarray.dtype)retval,img_buffer = cv2.imencode('.jpg', ndarray)img_str = base64.b64encode(img_buffer)requests.post("http://127.0.0.1:8879
·
python ndarray 与 base64 互转 post接口传递ndarry
1.ndarray转base64
print(ndarray.dtype)
retval,img_buffer = cv2.imencode('.jpg', ndarray)
img_str = base64.b64encode(img_buffer)
requests.post("http://127.0.0.1:8879/infer", {"image": img_str})
2.base64转ndarray
image = request.form.get("image")
img_str = base64.b64decode(image)
image_np = np.fromstring(img_str, dtype=np.uint8)
image_np = cv2.imdecode(image_np, cv2.IMREAD_COLOR)
更多推荐
所有评论(0)