-
Notifications
You must be signed in to change notification settings - Fork 0
/
attendance.py
352 lines (309 loc) · 7.61 KB
/
attendance.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
import tkinter as tk
from tkinter import *
import os, cv2
import shutil
import csv
import numpy as np
from PIL import ImageTk, Image
import pandas as pd
import datetime
import time
import tkinter.font as font
import pyttsx3
# project module
import show_attendance
import takeImage
import trainImage
import automaticAttedance
# engine = pyttsx3.init()
# engine.say("Welcome!")
# engine.say("Please browse through your options..")
# engine.runAndWait()
def text_to_speech(user_text):
engine = pyttsx3.init()
engine.say(user_text)
engine.runAndWait()
haarcasecade_path = r"C:\Users\Administrator\Desktop\VS code - prasanth\Attendance-Management-system-using-face-recognition-master\haarcascade_frontalface_default.xml"
trainimagelabel_path = (
"C:\Users\Administrator\Desktop\VS code - prasanth\Attendance-Management-system-using-face-recognition-master\TrainingImageLabel\Trainner.yml"
)
trainimage_path = "C:\Users\Administrator\Desktop\VS code - prasanth\Attendance-Management-system-using-face-recognition-master\TrainingImage"
studentdetail_path = (
"C:\Users\Administrator\Desktop\VS code - prasanth\Attendance-Management-system-using-face-recognition-master\StudentDetails\studentdetails.csv"
)
attendance_path = "C:\Users\Administrator\Desktop\VS code - prasanth\Attendance-Management-system-using-face-recognition-master\Attendance"
window = Tk()
window.title("Face recognizer")
window.geometry("1280x720")
dialog_title = "QUIT"
dialog_text = "Are you sure want to close?"
window.configure(background="black")
# to destroy screen
def del_sc1():
sc1.destroy()
# error message for name and no
def err_screen():
global sc1
sc1 = tk.Tk()
sc1.geometry("400x110")
sc1.iconbitmap("AMS.ico")
sc1.title("Warning!!")
sc1.configure(background="black")
sc1.resizable(0, 0)
tk.Label(
sc1,
text="Enrollment & Name required!!!",
fg="yellow",
bg="black",
font=("times", 20, " bold "),
).pack()
tk.Button(
sc1,
text="OK",
command=del_sc1,
fg="yellow",
bg="black",
width=9,
height=1,
activebackground="Red",
font=("times", 20, " bold "),
).place(x=110, y=50)
def testVal(inStr, acttyp):
if acttyp == "1": # insert
if not inStr.isdigit():
return False
return True
logo = Image.open("UI_Image/0001.png")
logo = logo.resize((50, 47), Image.ANTIALIAS)
logo1 = ImageTk.PhotoImage(logo)
titl = tk.Label(window, bg="black", relief=RIDGE, bd=10, font=("arial", 35))
titl.pack(fill=X)
l1 = tk.Label(window, image=logo1, bg="black",)
l1.place(x=470, y=10)
titl = tk.Label(
window, text="Vels College!!", bg="black", fg="green", font=("arial", 27),
)
titl.place(x=525, y=12)
a = tk.Label(
window,
text="Welcome to the Face Recognition Based\nAttendance Management System",
bg="black",
fg="yellow",
bd=10,
font=("arial", 35),
)
a.pack()
ri = Image.open("UI_Image/register.png")
r = ImageTk.PhotoImage(ri)
label1 = Label(window, image=r)
label1.image = r
label1.place(x=100, y=270)
ai = Image.open("UI_Image/attendance.png")
a = ImageTk.PhotoImage(ai)
label2 = Label(window, image=a)
label2.image = a
label2.place(x=980, y=270)
vi = Image.open("UI_Image/verifyy.png")
v = ImageTk.PhotoImage(vi)
label3 = Label(window, image=v)
label3.image = v
label3.place(x=600, y=270)
def TakeImageUI():
ImageUI = Tk()
ImageUI.title("Take Student Image..")
ImageUI.geometry("780x480")
ImageUI.configure(background="black")
ImageUI.resizable(0, 0)
titl = tk.Label(ImageUI, bg="black", relief=RIDGE, bd=10, font=("arial", 35))
titl.pack(fill=X)
# image and title
titl = tk.Label(
ImageUI, text="Register Your Face", bg="black", fg="green", font=("arial", 30),
)
titl.place(x=270, y=12)
# heading
a = tk.Label(
ImageUI,
text="Enter the details",
bg="black",
fg="yellow",
bd=10,
font=("arial", 24),
)
a.place(x=280, y=75)
# ER no
lbl1 = tk.Label(
ImageUI,
text="Enrollment No",
width=10,
height=2,
bg="black",
fg="yellow",
bd=5,
relief=RIDGE,
font=("times new roman", 12),
)
lbl1.place(x=120, y=130)
txt1 = tk.Entry(
ImageUI,
width=17,
bd=5,
validate="key",
bg="black",
fg="yellow",
relief=RIDGE,
font=("times", 25, "bold"),
)
txt1.place(x=250, y=130)
txt1["validatecommand"] = (txt1.register(testVal), "%P", "%d")
# name
lbl2 = tk.Label(
ImageUI,
text="Name",
width=10,
height=2,
bg="black",
fg="yellow",
bd=5,
relief=RIDGE,
font=("times new roman", 12),
)
lbl2.place(x=120, y=200)
txt2 = tk.Entry(
ImageUI,
width=17,
bd=5,
bg="black",
fg="yellow",
relief=RIDGE,
font=("times", 25, "bold"),
)
txt2.place(x=250, y=200)
lbl3 = tk.Label(
ImageUI,
text="Notification",
width=10,
height=2,
bg="black",
fg="yellow",
bd=5,
relief=RIDGE,
font=("times new roman", 12),
)
lbl3.place(x=120, y=270)
message = tk.Label(
ImageUI,
text="",
width=32,
height=2,
bd=5,
bg="black",
fg="yellow",
relief=RIDGE,
font=("times", 12, "bold"),
)
message.place(x=250, y=270)
def take_image():
l1 = txt1.get()
l2 = txt2.get()
takeImage.TakeImage(
l1,
l2,
haarcasecade_path,
trainimage_path,
message,
err_screen,
text_to_speech,
)
txt1.delete(0, "end")
txt2.delete(0, "end")
# take Image button
# image
takeImg = tk.Button(
ImageUI,
text="Take Image",
command=take_image,
bd=10,
font=("times new roman", 18),
bg="black",
fg="yellow",
height=2,
width=12,
relief=RIDGE,
)
takeImg.place(x=130, y=350)
def train_image():
trainImage.TrainImage(
haarcasecade_path,
trainimage_path,
trainimagelabel_path,
message,
text_to_speech,
)
# train Image function call
trainImg = tk.Button(
ImageUI,
text="Train Image",
command=train_image,
bd=10,
font=("times new roman", 18),
bg="black",
fg="yellow",
height=2,
width=12,
relief=RIDGE,
)
trainImg.place(x=360, y=350)
r = tk.Button(
window,
text="Register a new student",
command=TakeImageUI,
bd=10,
font=("times new roman", 16),
bg="black",
fg="yellow",
height=2,
width=17,
)
r.place(x=100, y=520)
def automatic_attedance():
automaticAttedance.subjectChoose(text_to_speech)
r = tk.Button(
window,
text="Take Attendance",
command=automatic_attedance,
bd=10,
font=("times new roman", 16),
bg="black",
fg="yellow",
height=2,
width=17,
)
r.place(x=600, y=520)
def view_attendance():
show_attendance.subjectchoose(text_to_speech)
r = tk.Button(
window,
text="View Attendance",
command=view_attendance,
bd=10,
font=("times new roman", 16),
bg="black",
fg="yellow",
height=2,
width=17,
)
r.place(x=1000, y=520)
r = tk.Button(
window,
text="EXIT",
bd=10,
command=quit,
font=("times new roman", 16),
bg="black",
fg="yellow",
height=2,
width=17,
)
r.place(x=600, y=660)
window.mainloop()