Skip to content

Instantly share code, notes, and snippets.

@danleyb2
Created February 21, 2022 08:42
Show Gist options
  • Save danleyb2/e17f8f7ad5aa5f5096c2c3817deca2f5 to your computer and use it in GitHub Desktop.
Save danleyb2/e17f8f7ad5aa5f5096c2c3817deca2f5 to your computer and use it in GitHub Desktop.
Encode an Image to Base64 then upload to Platerecognizer API cloud
import base64
import requests
API_TOKEN = '3234232ad2################'
def upload_base64(image_path):
with open(image_path, 'rb') as image_file:
img_base64 = base64.b64encode(image_file.read())
url = 'http://api.platerecognizer.com/v1/plate-reader'
r = requests.post(
url,
data=dict(
upload=img_base64
),
headers={
'Authorization': 'Token ' + API_TOKEN,
}
)
print(r.text)
return r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment