-
Notifications
You must be signed in to change notification settings - Fork 3
/
prediction.py
83 lines (71 loc) · 2.09 KB
/
prediction.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import preprocess
import plotting
import matplotlib.pyplot as plt
import pickle
import os
import sys
import database
model_pat=os.path.dirname(os.path.realpath(__file__))+"/model.sav"
model= pickle.load(open(model_pat,"rb"))
env=preprocess.Preprocess("test_image/car4.jpg")
env.plate_detection()
segmented_characters=env.character_segmentation()
plotting.show()
segmented_characters.sort()
ans=[]
for char in segmented_characters:
#print(plt.imshow(char[1]))
ans.append(model.predict(char[1].reshape(1,-1)))
license_plate= []
for val in ans:
license_plate.append(val[0])
for idx in range(len(license_plate)):
if(idx==0 or idx==1 or idx==4 or idx==5):
if(license_plate[idx]=='0'):
license_plate[idx]=str('O')
elif(license_plate[idx]=='1'):
license_plate[idx]=str('I')
elif(license_plate[idx]=='2'):
license_plate[idx]='Z'
else:
if(license_plate[idx]=='O'):
license_plate[idx]='0'
elif(license_plate[idx]=='I'):
license_plate[idx]='1'
elif(license_plate[idx]=='Z'):
license_plate[idx]=str('2')
license_plate="".join(license_plate)
print("Recognized License Plate is:")
print(license_plate)
if(license_plate==""):
print("Cannot detect a valid license plate")
sys.exit()
emps = database.get_emps_by_name(license_plate)
if(len(emps)==0):
print("Employee not in database")
sys.exit()
stack_car = ["1", "2", "3"]
stack_car.append("4")
stack_car.append("5")
stack_bike=["11","12","13","14","15"]
stack_truck=["6","7","8","9","10"]
if (emps[0][0]=="Car"):
print("Parking lot:")
print(stack_car.pop())
print("Type of vehicle:")
print(emps[0][0])
print("Price for vehicle:")
print(emps[0][2])
elif(emps[0][0]=="Bike"):
print("Parking lot:")
print(stack_bike.pop())
print("Type of vehicle:")
print(emps[0][0])
print("Price for vehicle:")
print(emps[0][2])
elif(emps[0][0]=="Truck"):
print("Parking lot:")
print(stack_truck.pop())
print("Type of vehicle:")
print(emps[0][0])
print("Price for vehicle:")