-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathface_recognizer_menu.py
127 lines (102 loc) · 3.08 KB
/
face_recognizer_menu.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
/*****************************************************
*
* Gabor Vecsei
* Email: [email protected]
* Blog: https://gaborvecsei.wordpress.com/
* LinkedIn: www.linkedin.com/in/vecsei-gabor
* Github: https://github.com/gaborvecsei
*
*****************************************************
"""
import os
import sys
def cls():
"""
# Clears the console's screen
"""
os.system('cls' if os.name == 'nt' else 'clear')
def mainMenu():
"""
# Goes to the main menu if the user presses x
"""
print 'Press (x) to go back to the main menu'
pressedKey = raw_input('')
if pressedKey == 'x' or pressedKey == 'X':
cls()
mainScreen()
else:
mainMenu()
def mainScreen():
"""
# Shows main screen where we can choose from the programs
"""
print "\n\nFace Recognizer --- Gabor Vecsei"
print "---------------------------------------------------------"
print "Press 1 to prepare images for training (from folder)"
print "Press 2 to prepare images for training (from webcam)"
print "Press 3 to train face recognizer"
print "Press 4 to reconize face from webcam image"
print "Press 5 to recognize face and create attendance sheet"
print "Press 6 for About"
print "Press 7 to exit"
print "---------------------------------------------------------\n\n"
selectedMenuPoint = raw_input("Enter the selected menu point and press ENTER: ")
print "\n\n"
# Start the chosen script
screenDict[eval(selectedMenuPoint)]()
# These are the menu options we can execute
# We run a .py script
def prepImagesFromFolder():
cls()
os.system("python prepare_faces_for_training.py")
mainMenu()
def prepImagesFromWebcam():
cls()
os.system("python prepare_faces_for_training_from_webcam.py")
answer = raw_input("Would you like to add another person? (y/n)")
if answer == 'y':
prepImagesFromWebcam()
mainMenu()
def trainFaceRecognizer():
cls()
os.system("python train_face_recognizer.py")
mainMenu()
def recognizeFromWebcam():
cls()
os.system("python recognize_face_on_camera.py")
mainMenu()
def recognizeFromWebcamAndCreateAttendanceSheet():
cls()
os.system("python recognize_face_create_attendance_sheet.py")
mainMenu()
def exit():
sys.exit(0)
def aboutScreen():
cls()
print " Facial recognition system made by Gabor Vecsei"
print " BME BSc Thesis"
print " 2016 December"
print """
/*****************************************************
*
* Gabor Vecsei
* Email: [email protected]
* Blog: https://gaborvecsei.wordpress.com/
* LinkedIn: www.linkedin.com/in/vecsei-gabor
* Github: https://github.com/gaborvecsei
*
*****************************************************
"""
mainMenu()
screenDict = {
1: prepImagesFromFolder,
2: prepImagesFromWebcam,
3: trainFaceRecognizer,
4: recognizeFromWebcam,
5: recognizeFromWebcamAndCreateAttendanceSheet,
6: aboutScreen,
7: exit
}
# Program starts here:
mainScreen()