发布base64转换后的图像数据

时间:2018-06-03 20:11:24

标签: c# python encoding http-post

C#中这个python代码的等价物是什么。 这将从文件打开图像并转换为base64编码的字符串并发送POST请求。 请帮忙。

#!/usr/bin/python

import requests
import base64
import json

# Sample image file is available at http://plates.openalpr.com/ea7the.jpg
IMAGE_PATH = '/tmp/sample.jpg'
SECRET_KEY = 'sk_DEMODEMODEMODEMODEMODEMO'

with open(IMAGE_PATH, 'rb') as image_file:
    img_base64 = base64.b64encode(image_file.read())

url = 'https://api.openalpr.com/v2/recognize_bytes?recognize_vehicle=1&country=us&secret_key=%s' % (SECRET_KEY)
r = requests.post(url, data = img_base64)

print(json.dumps(r.json(), indent=2))

1 个答案:

答案 0 :(得分:1)

未经测试,但足以让您从中开始。

intptr_t