Created
February 27, 2020 21:22
-
-
Save YKalashnikov/8617a1f2755270fae77180a33f63e5c0 to your computer and use it in GitHub Desktop.
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 | |
image_path = 'YOUR_IMAGE_PATH' | |
secret_key = 'YOUR_SECRET_KEY' | |
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=ru&secret_key={}'.format(secret_key) | |
r = requests.post(url, data = img_base64) | |
try: | |
print({ | |
'Plate': r.json()['results'][0]['plate'], | |
'Region': r.json()['results'][0]['region'], | |
'Brand': r.json()['results'][0]['vehicle']['make'][0]['name'], | |
'Color': r.json()['results'][0]['vehicle']['color'][0]['name'], | |
'Year': r.json()['results'][0]['vehicle']['year'][0]['name'] | |
}) | |
except: | |
print ('oops plate cannot be identified ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment