-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathStart.py
More file actions
81 lines (66 loc) · 2.05 KB
/
Start.py
File metadata and controls
81 lines (66 loc) · 2.05 KB
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
import os
import time
import datetime
import videosplit_sklearn as videosplit
import cv2
#import pymongo
import Launch
def mongo_connection():
con = pymongo.MongoClient(host,27017)
col = con[database][collection]
return col
if __name__ == '__main__':
name = str(input('Enter the name of the video: '))
(vdolength,totalFrames) = videosplit.Launch(name)
os.chdir('data')
result = {}
result_imag = {}
startTime = time.time()
for f in os.listdir():
pred, img = Launch.main(f)
if pred in result.keys():
result[pred] = result[pred] + 1
elif pred != ' ':
result[pred] = 1
result_imag[pred] = img
endTime = time.time()
l = {x: y for y, x in result.items()}
r = list(sorted(l.keys()))
index = r[len(r) - 1]
plate = l[index]
img = result_imag[plate]
executionTime = "{0:.2f}".format(endTime - startTime)
print('The name plate is :', plate, ' frequency is: ', result[plate])
try:
cv2.imshow('The plate', img)
except:
print("Problem in displaying license plate")
print('execution time is : ' + executionTime)
os.chdir('..')
licensePlatePath = './LicensePlates/'+name.split('.')[0]+'.jpg'
try:
cv2.imwrite(licensePlatePath,img)
except:
print("Problem in writing license plate image")
cv2.waitKey(0)
for i in result.keys():
print(i, ' : ', result[i])
#storing data in database
"""
host = 'localhost'
database = 'ALPR'
collection = 'videosTest'
try:
col = mongo_connection()
dict = {}
dict['date and time'] = time.ctime()
dict['video'] = name
dict['video length'] = vdolength
dict['image'] = plate
dict['Total Frames in video'] = totalFrames
dict['execution_time'] = executionTime
dict['frequency ratio'] = "{0:.2f}".format(result[plate] / len(result))
col.insert(dict)
except:
print("error in mongodb connection or insertion")
"""