-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
47 lines (35 loc) · 1.26 KB
/
main.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
import cv2
from tensorflow.keras.models import load_model
import classicalShapeDetection
import voting
def main():
models = []
model = load_model(".\\output\\germansignsnet3.7")
models.append(model)
model = load_model(".\\output\\germansignsnet1.8")
models.append(model)
model = load_model(".\\output\\germansignsnet4.4")
models.append(model)
labelNames = open("signnames.csv").read().strip().split("\n")[1:]
labelNames = [l.split(",")[1] for l in labelNames]
vidcap = cv2.VideoCapture('video/video5.mp4')
label = None
while True:
success, frame = vidcap.read()
if success is False:
break
coordinate, image, sign = classicalShapeDetection.localization(frame, 300, 0.65)
if sign is not None:
# yoloShapeDetection.recognizeObjects(image, confidence_thresh=0.4)
j = voting.vote_on_image(models, sign)
if j is not None:
label = labelNames[j]
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.putText(frame, label, (5, 15), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 255), 2)
cv2.imshow("Video", frame)
vidcap.release()
cv2.destroyAllWindows()
classicalShapeDetection.end()
main()