-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplate.py
59 lines (43 loc) · 1.63 KB
/
plate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import urllib2
import xml.etree.ElementTree
import json
import sys
from openalpr import Alpr
config = "path to the openalpr.conf file" #change
runtimeData = "path to the openalpr runtime_data folder" #change
alpr = Alpr("aus", config, runtimeData)
if not alpr.is_loaded():
print("Error loading OpenALPR")
sys.exit(1)
alpr.set_top_n(1)
image = "path to image to get license plate" #change
results = alpr.recognize_file(image)
plates = []
for plate in results['results']:
for candidate in plate['candidates']:
plates.append(candidate['plate'])
break
# Call when completely done to release memory
alpr.unload()
#this is username of the fake email
username = "kek"
for plate in plates:
#get the webpage
page = urllib2.urlopen("http://www.regcheck.org.uk/api/reg.asmx/CheckAustralia?RegistrationNumber=" + plate + "&State=NSW&username=" +username)
#get the root of the file of the xml response
root = e = xml.etree.ElementTree.parse(page).getroot()
#get the json text concerning the details of the vehicle
j = root[0].text
d = json.loads(j)
#if the colour is unable to be obtained
string = d["Colour"]
if string == "":
string = "N/A"
#print details
print "The car is a", d["Description"]
print "The state the car is licensed under is", d["State"]
print "The year is was registered was", d["RegistrationYear"]
print "The colour of the car is", string
print "The vehicle identification number is", d["VechileIdentificationNumber"]
#can change that so the user can download the image etc
print "An image of the car is obtainable by this url", d["ImageUrl"]