
I realise this is an old topic, BUT, I had the same exact thought... I've done some testing...
it's not super fast but I did find a sloppy method of doing this! (I've yet to code any actions based on the response other than printing out the results).
This gives you 2000 free API Credits a month, the equivalent of about 64 lookups per day... or 32 if you want the vehicle details returned as well as just the reg
2) Make a bash script file, for example, in /data/output/Camera1/ name whatever you like. For example: test.sh
3) Here's the code I used:
if [ -z "$1" ]
then
echo -e "\nNo argument supplied\n"
exit 1
fi
file=$1
if [ -f "$file" ]
then
#echo "$file found."
python test.py
exit 1
else
echo "$file not found."
exit 1
fi
Replace
YOUR_SECRET_KEY with the Secret Key provided in your API page (https://cloud.openalpr.com/cloudapi)
Replace YOUR_COUNTRY_CODE with your country code. GB for Great Britain, EU for other European plates. Check their website for country codes available
If you use 'recognize_vehicle=1' - then it costs 2 API credits per search and will also return the vehicle make, model, colour etc etc.
If you use 'recognize_vehicle=0' - then it only costs 1 API credit and only returns the Number Plate.
The CURL link in the script has an argument - $1. This would be the image file you want to send. It's worth noting that in your file storage location, there is an alias called 'lastsnap.jpg' which is the last stored still image.
As an example, if my output folder was: /data/output/Camera1/
Then I would use:
./test.sh /data/output/Camera1/lastsnap.jpg
And it will therefore always send the most recent captured still image to be checked.
Once the results file is saved (CURL saves the output to 'results.json'), I then use some python to break it down - my 'test.py' file is as follows:
import json
from pprint import pprint
with open('results.json') as f:
data = json.load(f)
#pprint(data)
if len(data['results']) > 0:
print("\nLicense Plate: " + data['results'][0]['plate'])
print("Vehicle: " + data['results'][0]['vehicle']['make_model'][0]['name'].title().replace("_"," "))
print("Year: " + data['results'][0]['vehicle']['year'][0]['name'].title())
print("Color: " + data['results'][0]['vehicle']['color'][0]['name'].title())
print("\nCredits Used: " + str(data['credits_monthly_used']) + " out of " + str(data['credits_monthly_total']) + "\n")
else:
print("\nNo vehicle data found")
print("\nCredits Used: " + str(data['credits_monthly_used']) + " out of " + str(data['credits_monthly_total']) + "\n")
Please note
1) This assumes you ARE using 'recognize_vehicle=1' and thus is coded specifically for that usage.
2) I was originally trying to write a script in python using requests, but requests isn't installed, and you CAN'T install it if you're using the MotionEyeOS like I am. I did try with httplib but failed with that too. So I then made the bash script so I could just use CURL... the decoding of the json I had already written in python, hence why at this stage it's half bash (.sh file) and then half pyhon (.py file).
I will try and update my bash script so that it does all the work itself, and doesn't need a separate python file... it just so happened to be my progress at the time as I realised some stuff I couldn't do in python and couldn't install the needed add-ons (eg python-requests)