Created
February 21, 2022 08:42
-
-
Save danleyb2/e17f8f7ad5aa5f5096c2c3817deca2f5 to your computer and use it in GitHub Desktop.
Encode an Image to Base64 then upload to Platerecognizer API cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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