BlackBook Format
BlackBook Format
In
Computer Engineering
“Face Detection Attendance
System” Face-Flex
1802- Swarnim
Bane 1854-Vedant
Raut
1855-Atharva
Sankhe 1861-Harsh
Tandel
GUIDED BY
VASAI (W)-401202
Year 2023-2024
Copyright © 2023-2024 Vidyavardhni’s Bhausaheb Vartak Polytechnic, Computer Engineering
VIDYAVARDHINI’S BHAUSAHEB VARTAK POLYTECHNIC
VASAI ROAD (W)
CERTIFICATE
This is to certify that Mr. /Ms. Swarnim Sachin Bane, Vedant Nitin Raut,
Atharva Nitin Sankhe, Harsh Satish Tandel from Vidyavardhini’s Bhausaheb
Vartak Polytechnic having Enrolments No. 2100930075, 2100930178,
2100930179 & 210930188 respectively, have satisfactorily Completed the Project
Titled “Face Detection Attendance System” during the year 2023-2024 as per
curriculum laid down by MSBTE in partial Fulfilment of the award of Diploma in
Computer Engineering.
Principal
We have great pleasure and satisfaction in presenting this project report on “Face
Detection Attendance System” We take this opportunity to express our sincere
thanks to all those people who helped us to complete our project successfully.
We would like to express our special thanks of gratitude to Prof. Parvez Vaghela for
technical extend & constant encouragement. We are also thankful to the staff for
rendering their support during the Project Period.
We are also thankful to our friend and colleagues. Their worthy support made an
encouraging environment to work within. Finally, we would like to thank all the
people directly or indirectly concerned within projects.
Names:
Swarnim Bane
Vedant Raut
Atharva Sankhe
Harsh Tandel
Abstract
iii
Achievements iv-v
List of Figures vi
1.1) Introduction 2
2.3) Constraint’s 6
3.1) Flowchart 9
5 CODE 30-69
5.1) Login.py 30
5.2) Main.py 35
5.3) Student.py 39
5.4) Train.py 54
5.5) Register.py 56
5.6) FaceRecognition.py 60
5.7) Attendence.py 63
6 ALGORITHM 70
6.1) Algorithm to train faces we use LBPH 71
algorithm
7 TESTING 76
7.1) Introduction 77
In the era of modern technologies emerging at rapid pace there is no reason why a
crucial event in educational sector such as attendance should be done in the old boring
traditional way.
Attendance monitoring system will save a lot of time and energy for the both parties
students as well as the class teachers. Attendance will be monitored by the face
recognition algorithm by recognizing only the face of the students from the rest of the
objects and then marking them as present. The system will be pre feed with the images
of all the students and with the help of this pre feed data the algorithm will detect them
who are present and match the features with the already saved images of them present
in the database.
3.1 Flowchart 9
3.4 ER Diagram 12
LITERATURE SURVEY
FACE-FLEX
1. Face Detection: The system uses computer vision algorithms to detect and
locate human faces within a given frame, whether from images or live video
feeds.
2. Face Recognition: Once faces are detected, the system employs facial
recognition techniques to match them against a database of known individuals.
This database typically contains pre-registered faces along with associated
metadata such as names, IDs, and other relevant information.
4. Insights: The system generates valuable insights into attendance patterns and
trends, enabling administrators to make data-driven decisions and optimize
resource allocation.
1. Face Detection: Initially, the system detects the presence of faces within a given
image or video frame. This is usually done using techniques like Haar cascades,
HOG (Histogram of Oriented Gradients), or deep learning-based approaches
like Convolutional Neural Networks (CNNs).
2. Face Recognition: Once faces are detected, the system identifies individuals by
comparing the detected faces with a database of known faces. This involves
extracting facial features and comparing them against pre-registered faces using
methods like Eigenfaces, Fisherfaces, Local Binary Patterns (LBP), or more
advanced deep learning techniques like FaceNet or VGGFace.
2. Efficiency: The system automates the attendance tracking process, saving time
for both employees and administrators.
3. Convenience: Employees can clock in and out simply by showing their faces,
eliminating the need for physical cards or biometric devices.
6. Data Insights: It provides valuable insights into attendance patterns and trends,
facilitating better decision-making for resource planning and management.
REQUIRMENT ANALYSIS
FACE-FLEX
Some of the most common constraints to deal with are listed below.
Some of these are softconstraints meaning they only increase the cost.
Some are hard which cannot be violated.
1. Hard Constraints:
● No student must be allowed to login/register into the system without the
teacher id and password
● Each student must be registered or can register in the system by adding their
details
● Student cannot add their wrong details
2. Soft Constraints:
● The attendance report can be exported to different csv(Excel) file.
Some of the most important features offered by our web application are:-
SYSTEM DESIGN
FACE-FLEX
Login Login
Face detection Teacher
Student
attendance system
Response Response
Response
Database
1. REGISTRATION
2. LOGIN
3. FORGET PASSWORD
4. LOGIN PAGE
This is the main login page of our application where, the user will be directed to
the application if the user enters the correct details and logs in, if the user isn’t
registered he/she can register new account and if the user forgets his her details
he/she can use the forget password to change the details and login to the
application.
After the registration, the user gets redirected to the main project.
The details of the student when added it will appear in the table section, as well as it
will get added into the database
The attendance will appear for the desired/selected class and branch.
Fig.3.5.7 DB view
The images will get trained here using the LBPH face recognition algorithm
The main reason to store the attendance in the csv file was to improve the accesibility
of the marked attendance and make it portable and easily transfferable to another csv
file according to the user comfortness.
The CSV file data will be displayed in this table section and you can also update
the data of the csv file through the application
IMPLEMENTATION
FACE-FLEX
You can click any of the icons mentioned above, depending on the operating system
for which you are planning to download the visual studio code editor.
Firstly, download the Visual Studio Code installer for Windows. Once it is
downloaded, run the installer (VSCodeUserSetup-{version}.exe). It will only take a
minute.
Thirdly, click on "create a desktop icon" so that it can be accessed from desktop and click o
Step 1: Go to https://dev.mysql.com/downloads/mysql/
Step 3 – Add root name and its password according to the user comfort
and accessibility
def main_log():
win=Tk()
app=Login_Window(win)
win.mainloop()
class Login_Window:
img3 =
Image.open("college_images/employee_img2.jpg")
img3 = img3.resize((1710, 1150))
self.photoimg3 = ImageTk.PhotoImage(img3)
bg_img = Label(self.root,
image=self.photoimg3) bg_img.place(x=0,
y=0, width=1710, height=1050)
frame1= Frame(self.root,bg="#002B53")
frame1.place(x=680,y=200,width=380,height
=480)
img1=Image.open("college_images/LoginIconAppl.png")
img1=img1.resize((100,100))
self.photoimage1=ImageTk.PhotoImage(img1)
lb1img1 =
Label(image=self.photoimage1,bg="#002B53")
lb1img1.place(x=820,y=210, width=100,height=100)
#label1
username =lb1= Label(frame1,text="Username:",font=("times new
roman",16,"bold"),fg="white",bg="#002B53") username.place(x=30,y=160)
#entry2
self.txtpwd=ttk.Entry(frame1,font=("times new roman",16,"bold"))
self.txtpwd.place(x=33,y=260,width=270)
#==========================functions ===========================
def reg(self):
self.new_window=Toplevel(self.ro
ot)
self.app=Register(self.new_windo
w)
def login(self):
if (self.txtuser.get()=="" or self.txtpwd.get()==""):
messagebox.showerror("Error","All Field Required!")
elif(self.txtuser.get()=="admin" and self.txtpwd.get()=="admin"):
messagebox.showinfo("Sussessfully","Welcome to Attendance Managment System Using Facial
Recognition",parent=self.root)
else:
conn=mysql.connector.connect(host="localhost",user="root",password="swarnim0129",database=
"login
_schema",auth_plugin='mysql_native_passwor
d') mycursor = conn.cursor()
mycursor.execute("select * from register where email=%s and password=
%s",( self.txtuser.get(),
self.txtpwd.get()
))
row=mycursor.fetchon
e() if row==None:
Copyright © 2023-2024 Vidyavardhni’s Bhausaheb Vartak Polytechnic, Computer 32
Engineering
messagebox.showerror("Error","Invalid Username and
Password!") else:
open_min=messagebox.askyesno("YesNo","Access only Admin")
def reset_pass(self):
if self.combo_security.get()=="Select":
messagebox.showerror("Error","Select the Security Question!",parent=self.root2)
elif(self.var_sa.get()==""):
messagebox.showerror("Error","Please Enter the Answer!",parent=self.root2)
elif(self.new_pwd.get()==""):
messagebox.showerror("Error","Please Enter the New
Password!",parent=self.root2) else:
conn=mysql.connector.connect(host="localhost",user="root",password="swarnim0129",database=
"login
_schema",auth_plugin='mysql_native_passwor
d') mycursor = conn.cursor()
query=("select * from register where email=%s and securityQ=%s and
securityA=%s")
value=(self.txtuser.get(),self.combo_security.get(),self.var_sa.get())
mycursor.execute(query,value)
row=mycursor.fetchon
e() if row==None:
messagebox.showerror("Error","Please Enter the Correct
Answer!",parent=self.root2) else:
query=("update register set password=%s where email=%s")
value=(self.new_pwd.get(),self.txtuser.get())
mycursor.execute(query,value)
conn.commit()
conn.close()
messagebox.showinfo("Info","Successfully Your password has been rest, Please login with new
Password!",parent=self.root2)
def ret_login(self):
self.root.destroy
()
def forget_pwd(self):
if self.txtuser.get()=="":
messagebox.showerror("Error","Please Enter the Email ID to reset
Password!") else:
if row==None:
messagebox.showerror("Error","Please Enter the Valid Email ID!")
else:
conn.close()
self.root2=Toplevel()
self.root2.title("Forget
Password")
self.root2.geometry("380x480+680+240")
l=Label(self.root2,text="Forget Password",font=("times new
roman",30,"bold"),fg="#002B53",bg="#fff") l.place(x=0,y=10,relwidth=1)
# fields
#label1
ssq =lb1= Label(self.root2,text="Select Security Question:",font=("times new
roman",15,"bold"),fg="#002B53",bg="#F2F2F2")
ssq.place(x=70,y=80)
#Combo Box1
self.combo_security = ttk.Combobox(self.root2,font=("times new roman",15,"bold"),state="readonly")
self.combo_security["values"]=("Select","Your Date of Birth","Your Nick Name","Your Favorite Book")
self.combo_security.current(0)
self.combo_security.place(x=70,y=110,width=270)
#label2
sa =lb1= Label(self.root2,text="Security Answer:",font=("times new
roman",15,"bold"),fg="#002B53",bg="#F2F2F2")
sa.place(x=70,y=150)
#entry2
self.var_sa=ttk.Entry(self.root2,font=("times new roman",15,"bold"))
self.var_sa.place(x=70,y=180,width=270)
#label2
new_pwd =lb1= Label(self.root2,text="New Password:",font=("times new
roman",15,"bold"),fg="#002B53",bg="#F2F2F2")
new_pwd.place(x=70,y=220)
#entry2
self.new_pwd=ttk.Entry(self.root2,font=("times new roman",15,"bold"))
self.new_pwd.place(x=70,y=250,width=270)
Main.py
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import tkinter
from PIL import
Image,ImageTk from student
import Student from train
import Train
from face_recognition import Face_Recognition
#edited
class Face_Recognition_System:
def init (self,root):
self.root=root
self.root.geometry("1710x1050+0+0")
self.root.title("face recognition system")
img1 = Image.open("./college_images/Attendance
Banner.jpeg") img1 = img1.resize((1800, 395))
self.photoimg1 =
ImageTk.PhotoImage(img1) f_lbl =
Label(self.root, image=self.photoimg1)
f_lbl.place(x=0, y=0, width=1800,
height=130)
# bg img
img3 =
Image.open("./college_images/backAcademic.jpeg")
img3 = img3.resize((1710, 1050))
self.photoimg3 = ImageTk.PhotoImage(img3)
bg_img = Label(self.root,
image=self.photoimg3) bg_img.place(x=0,
y=130, width=1710, height=1050)
# student button
img4 =
Image.open("./college_images/studentInfoButton2.png")
img4 = img4.resize((305, 305))
self.photoimg4 = ImageTk.PhotoImage(img4)
b1 = Button(bg_img, image=self.photoimg4,command=self.student_details,
cursor="hand2") b1.place(x=310, y=140, width=220, height=220)
# Attendance button
img6 =
Image.open("./college_images/forbidden.png")
img6 = img6.resize((220, 220))
self.photoimg6 = ImageTk.PhotoImage(img6)
b1 = Button(bg_img, image=self.photoimg6,command=self.attendance_details,
cursor="hand2") b1.place(x=1120, y=140, width=220, height=220)
b1 = Button(bg_img, image=self.photoimg8,
command=self.train_details,cursor="hand2") b1.place(x=310, y=480, width=220,
height=220)
# Photos Button
img9 =
Image.open("./college_images/photosImg.png")
img9 = img9.resize((350, 350))
self.photoimg9 = ImageTk.PhotoImage(img9)
# Developer Button
img10 =
Image.open("./college_images/DevImg.webp")
img10 = img10.resize((237, 237))
self.photoimg10 = ImageTk.PhotoImage(img10)
#===========================function buttons=========================================
def student_details(self):
self.new_window=Toplevel(self.root)
self.app=Student(self.new_window)
def train_details(self):
self.new_window=Toplevel(self.root)
self.app=Train(self.new_window)
def face_detector(self):
self.new_window=Toplevel(self.root)
self.app=Face_Recognition(self.new_window)
def attendance_details(self):
self.new_window=Toplevel(self.root)
self.app=Attendance(self.new_window)
def developer_details(self):
self.new_window=Toplevel(self.root)
self.app=Developer(self.new_window)
class Student:
#=====================variables=============================
# img = Image.open("./college_images/facialrecognition.png")
# img = img.resize((1710, 130))
# self.photoimg = ImageTk.PhotoImage(img)
# f_lbl = Label(self.root,
image=self.photoimg)
# f_lbl.place(x=0, y=0, width=1710, height=130)
img=Image.open("./college_images/scanning-
banner.png") img=img.resize((600,130))
self.photoimg=ImageTk.PhotoImage(img)
f_lbl =Label(self.root,image=self.photoimg)
f_lbl.place(x=0,y=0,width=600,height=130)
img1 =
Image.open("./college_images/facialrecognition.png")
img1 = img1.resize((600, 130))
self.photoimg1 =
ImageTk.PhotoImage(img1) f_lbl =
Label(self.root, image=self.photoimg1)
f_lbl.place(x=600, y=0, width=600,
height=130)
img2 = Image.open("./college_images/facial-recognition-system-
banner.jpeg") img2 = img2.resize((600, 130))
self.photoimg2 =
ImageTk.PhotoImage(img2) f_lbl =
Label(self.root, image=self.photoimg2)
f_lbl.place(x=1200, y=0, width=600,
height=130)
# bg img
img3 =
Image.open("./college_images/gradimg2.webp")
img3 = img3.resize((1720, 1050))
self.photoimg3 = ImageTk.PhotoImage(img3)
title_lbl=Label(bg_img,text="STUDENT RECORDS",font=("verdana",35,"bold"),bg="white",fg="darkgreen");
title_lbl.place(x=0,y=0,width=1710,height="45")
img_left =
Image.open("./college_images/Canvastudentsbanner.webp")
img_left = img_left.resize((800, 130))
self.photoimg_left =
ImageTk.PhotoImage(img_left) f_lbl =
Label(left_frame, image=self.photoimg_left)
f_lbl.place(x=1, y=0, width=813, height=130)
#department
dep_label=Label(current_course_frame,text="Department",font=("verdana",16,"bold"),bg="white",fg="
navyblue") dep_label.grid(row=0,column=0,padx=10)
dep_combo=ttk.Combobox(current_course_frame,textvariable=self.var_dep,font=("verdana",16,"bold"),s
tate=" readonly",width=20)
dep_combo["values"]=("Select Department","Computer","Civil","Mechanical","BD")
dep_combo.current(0)
dep_combo.grid(row=0,column=1,padx=3,pady=10)
year_combo=ttk.Combobox(current_course_frame,textvariable=self.var_year,font=("verdana",16,"bold")
,state
="readonly",width=20)
year_combo["values"]=("Select Year","First Year","Second Year","Third Year")
year_combo.current(0)
year_combo.grid(row=0,column=4,pady=10)
sem_combo=ttk.Combobox(current_course_frame,textvariable=self.var_semester,font=("verdana",16,"b
Copyright © 2023-2024 Vidyavardhni’s Bhausaheb Vartak Polytechnic, Computer 45
Engineering
old"),s tate="readonly",width=20)
class_combo=ttk.Combobox(current_course_frame,textvariable=self.var_class,font=("verdana",16,"bold"
),stat e="readonly",width=20)
class_combo["values"]=("Select
Class","FYCO1","FYCO2","SYCO1","SYCO2","TYCO1","TYCO2","FYBD","SYBD","TYBD","FYCE1","FYCE2","
SYCE1","SYCE2","TYCE1","TYCE2","FYME1","FYME2","SYME1","SYME2","TYME1","TYME2")
class_combo.current(0)
class_combo.grid(row=1,column=4,pady=10)
#Student id
studentId_label = Label(class_Student_frame,text="Std-
ID:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
studentId_label.grid(row=0,column=0,padx=5,pady=5,sticky=W)
studentId_entry =
ttk.Entry(class_Student_frame,textvariable=self.var_std_id,width=15,font=("verdana",16,"bold"))
studentId_entry.grid(row=0,column=1,padx=5,pady=5,sticky=W)
#Student name
student_name_label = Label(class_Student_frame,text="Std-
Name:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
student_name_label.grid(row=0,column=2,padx=5,pady=5,sticky=W)
student_name_entry =
ttk.Entry(class_Student_frame,textvariable=self.var_std_name,width=15,font=("verdana",16,"bold"))
student_name_entry.grid(row=0,column=3,padx=5,pady=5,sticky=W)
#Phone Number
student_mob_label = Label(class_Student_frame,text="Mob-
No:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
student_mob_label.grid(row=1,column=0,padx=5,pady=5,sticky=W)
student_mob_entry =
ttk.Entry(class_Student_frame,textvariable=self.var_phone,width=15,font=("verdana
#Roll No
student_roll_entry =
ttk.Entry(class_Student_frame,textvariable=self.var_roll,width=15,font=("verdana",16,"bold"))
student_roll_entry.grid(row=1,column=3,padx=5,pady=5,sticky=W)
#Gender
student_gender_label =
Label(class_Student_frame,text="Gender:",font=("verdana",16,"bold"),fg="navyblue
",bg="white") student_gender_label.grid(row=2,column=0,padx=5,pady=5,sticky=W)
#combo box
gender_combo=ttk.Combobox(class_Student_frame,textvariable=self.var_gender,width=13,font=("verda
na",1 6,"bold"),state="readonly")
gender_combo["values"]=("Male","Female","Others")
gender_combo.current(0)
gender_combo.grid(row=2,column=1,padx=5,pady=5,s
ticky=W) #Date of Birth
student_dob_label =
Label(class_Student_frame,text="DOB:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
student_dob_label.grid(row=2,column=2,padx=5,pady=5,sticky=W)
student_dob_entry =
ttk.Entry(class_Student_frame,width=15,textvariable=self.var_dob,font=("verdana",16,"bold"))
student_dob_entry.grid(row=2,column=3,padx=5,pady=5,sticky=W)
#Email
student_email_label =
Label(class_Student_frame,text="Email:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
student_email_label.grid(row=3,column=0,padx=5,pady=5,sticky=W)
student_email_entry =
ttk.Entry(class_Student_frame,width=15,textvariable=self.var_email,font=("verdana
",16,"bold")) student_email_entry.grid(row=3,column=1,padx=5,pady=5,sticky=W)
#Address
student_address_label =
Label(class_Student_frame,text="Address:",font=("verdana",16,"bold"),fg="navyblue",bg="white")
student_address_label.grid(row=3,column=2,padx=5,pady=5,sticky=W)
student_address_entry =
ttk.Entry(class_Student_frame,width=15,textvariable=self.var_address,font=("verdana",16,"bold"))
student_address_entry.grid(row=3,column=3,padx=5,pady=5,sticky=W)
#Radio Buttons
self.var_radio1=StringVar()
radiobtn1=ttk.Radiobutton(class_Student_frame,variable=self.var_radio1,text="Take Photo
#Button Frame
btn_frame = Frame(left_frame,bd=2,bg="white",relief=RIDGE)
btn_frame.place(x=5,y=605,width=805,height=45)
#save button
save_btn=Button(btn_frame,text="Save",command=self.add_data,width=14,font=("verdana",16,"bold"),
fg="bla ck",bg="navyblue")
save_btn.grid(row=0,column=0,padx=5,pady=10,sticky=W)
#update button
update_btn=Button(btn_frame,text="Update",command=self.update_data,width=14,font=("verdana",16
,"bold"), fg="black",bg="navyblue")
update_btn.grid(row=0,column=1,padx=5,pady=8,sticky=W)
#delete button
del_btn=Button(btn_frame,text="Delete",command=self.delete_data,width=14,font=("verdana",16,"bold
"),fg="b lack",bg="navyblue")
del_btn.grid(row=0,column=2,padx=5,pady=10,sticky=W)
#reset button
reset_btn=Button(btn_frame,text="Reset",command=self.reset_data,width=14,font=("verdana",16,"bold
"),fg="b lack",bg="navyblue")
reset_btn.grid(row=0,column=3,padx=5,pady=10,sticky=W)
#Button Frame
btn2_frame = Frame(left_frame,bd=2,bg="white",relief=RIDGE)
btn2_frame.place(x=5,y=655,width=805,height=35)
img_right = Image.open("./college_images/studdetailsbaner.png")
search_frame = LabelFrame(right_frame,bd=2,bg="white",relief=RIDGE,text="Search
System",font=("verdana",20,"bold"),fg="navyblue")
search_frame.place(x=5,y=135,width=805,height=100)
search_label = Label(search_frame,text="Search
By:",font=("verdana",17,"bold"),fg="darkgreen",bg="white")
search_label.grid(row=0,column=0,padx=5,pady=10,sticky=W)
search_combo=ttk.Combobox(search_frame,font=("verdana",16,"bold"),textvariable=self.var_searchTX,
state= "readonly",width=13)
search_combo["values"]=("Select","Roll No")
search_combo.current(0)
search_combo.grid(row=0,column=1,padx=2,pady=10,stick
y=W)
search_entry = ttk.Entry(search_frame,textvariable=self.var_search,width=13,font=("verdana",17,"bold"))
search_entry.grid(row=0,column=2,padx=5,pady=10,sticky=W)
search_btn=Button(search_frame,text="Search",width=9,command=self.search_data,font=("verdana",1
7,"bold "),fg="black",bg="white")
search_btn.grid(row=0,column=3,padx=3)
showAll_btn=Button(search_frame,text="Show
All",command=self.fetch_data,width=8,font=("verdana",17,"bold"),fg="black",bg="
white")
showAll_btn.grid(row=0,column=4,padx=3)
#table frame
table_frame = Frame(right_frame,bd=2,bg="white",relief=RIDGE)
table_frame.place(x=5,y=245,width=805,height=400)
#scroll bar
scroll_x =
ttk.Scrollbar(table_frame,orient=HORIZONTAL) scroll_y
= ttk.Scrollbar(table_frame,orient=VERTICAL)
self.student_table=ttk.Treeview(table_frame,column=("Department","Class","Year","Sem","Id","Name","
Roll-
No","Gender","DOB","Email","Phone","Address","Photo"),xscrollcommand=scroll_x.set,yscrollcomm
and=scroll_ y.set)
scroll_x.pack(side=BOTTOM,fill=X)
scroll_y.pack(side=RIGHT,fill=Y)
self.student_table.heading("Department",text="Department")
self.student_table.heading("Class",text="Class")
self.student_table["show"]="headings"
self.student_table.column("Department",width
=100)
self.student_table.column("Class",width=100)
self.student_table.column("Year",width=100)
self.student_table.column("Sem",width=100)
self.student_table.column("Id",width=100)
self.student_table.column("Name",width=100)
self.student_table.column("Roll-
No",width=100)
self.student_table.column("Gender",width=10
0)
self.student_table.column("DOB",width=100)
self.student_table.column("Email",width=140)
self.student_table.column("Phone",width=100)
self.student_table.column("Address",width=10
0)
self.student_table.column("Photo",width=100)
#
self.student_table.column("Gender",width=100)
# self.student_table.column("DOB",width=100)
# self.student_table.column("Teacher",width=100)
self.student_table.pack(fill=BOTH,expand=1)
self.student_table.bind("<ButtonRelease>",self.get_curs
or) self.fetch_data()
# ====================function declarrtion======================
conn=mysql.connector.connect(host="localhost",user="root",password="swarnim0129",database="face_recogniz
er",aut h_plugin='mysql_native_password')
my_cursor=conn.cursor()
my_cursor.execute("insert into student values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",(
self.var_dep.get(),
self.var_class.get(),
# ========================fetch data=======================
def fetch_data(self):
conn = mysql.connector.connect(host="localhost", user="root",
password="swarnim0129", database="face_recognizer",
auth_plugin='mysql_native_password')
my_cursor = conn.cursor()
my_cursor.execute("select * from student")
data=my_cursor.fetchall()
if len(data)!=0:
self.student_table.delete(*self.student_table.get_childr
en()) for i in data:
self.student_table.insert("",END,values=i)
conn.commit()
conn.close()
# =========================get cursor=========================
#=========================update function=====================
def update_data(self):
if self.var_dep.get()=="Select Department"or self.var_std_name.get()=="" or self.var_std_id=="":
messagebox.showerror("Error","All fields are required",parent=self.root)
else:
try:
Update=messagebox.askyesno("Update","Do you want to update this student
details",parent=self.root) if Update>0:
conn = mysql.connector.connect(host="localhost", user="root",
password="swarnim0129",database="face_recognizer",
auth_plugin='mysql_native_password')
my_cursor = conn.cursor()
my_cursor.execute("Update student set
Dep=%s,Class=%s,Year=%s,Semester=%s,Name=%s,Roll=%s,Gender=%s,DOB=%s,Email=
%s,Ph one=%s,Address=%s,Photo=%s where Student_id=%s",(
self.var_dep.get(),
self.var_class.get(),
self.var_year.get(),
self.var_semester.get(),
self.var_std_name.get
(),
self.var_roll.get(),
self.var_gender.get
(),
self.var_dob.get(),
self.var_email.get()
,
self.var_phone.get(
),
self.var_address.get(
), self.var_radio1.get(),
self.var_std_id.get()
))
else:
if not Update:
return
messagebox.showinfo("Success","Student Details successfully
updated",parent=self.root) conn.commit()
self.fetch_data()
conn.close()
except Exception as es:
messagebox.showerror("Error",f"Due to:{str(es)}",parent=self.root)
# ===========================delete function====================
# =================================search data===========================
def search_data(self):
if self.var_search.get()=="" or self.var_searchTX.get()=="Select":
messagebox.showerror("Error","Select Combo option and enter entry
box",parent=self.root) else:
try:
conn = mysql.connector.connect(host="localhost", user="root",
conn.close()
except Exception as es:
messagebox.showerror("Error",f"Due To :{str(es)}",parent=self.root)
else:
try:
self.var_semester.get(),
self.var_std_name.get
(),
self.var_roll.get(),
self.var_gender.get
(),
self.var_dob.get(),
self.var_email.get()
,
self.var_phone.get(
),
self.var_address.get(),
self.var_radio1.get(),
self.var_std_id.get()==id+1
))
conn.commit()
self.fetch_data()
self.reset_data()
conn.close()
def face_cropped(img):
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces=face_classifier.detectMultiScale(gray,1.3,5)
cap=cv2.VideoCapture(0)
img_id=0
while True:
ret,my_frame=cap.read()
if face_cropped(my_frame) is not None:
img_id+=1
face=cv2.resize(face_cropped(my_frame),(500,500))
face=cv2.cvtColor(face,cv2.COLOR_BGR2GRAY)
file_name_path="data/user."+str(id)+"."+str(img_id)+".jpg"
cv2.imwrite(file_name_path,face)
cv2.putText(face,str(img_id),(50,50),cv2.FONT_HERSHEY_COMPLEX,2,(0,0,0),2) #white color
cv2.imshow("Cropped face",face)
if cv2.waitKey(1)==13 or
int(img_id)==180: break
cap.release()
Copyright © 2023-2024 Vidyavardhni’s Bhausaheb Vartak Polytechnic, Computer 61
Engineering
cv2.destroyAllWindows()
messagebox.showinfo("Result","Generating Datasets
Completed ")
Train.py
from tkinter import *
from tkinter import ttk
class Train:
def init (self, root):
self.root = root
self.root.geometry("1710x1150+0
+0") self.root.title("Training
Panel")
img3 =
Image.open("./college_images/trainBGBG.png")
img3 = img3.resize((1710, 1050))
self.photoimg3 = ImageTk.PhotoImage(img3)
bg_img = Label(self.root,
image=self.photoimg3) bg_img.place(x=0,
y=58, width=1710, height=1050)
def train_classifier(self):
data_dir = "data"
path = [os.path.join(data_dir, file) for file in os.listdir(data_dir) if
file.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))]
faces = []
ids = []
total_images = len(path)
self.current_idx = 0
cv2.destroyAllWindows()
messagebox.showinfo("Result", "Training dataset completed!!", parent=self.root)
Register.py
from tkinter import *
from tkinter import ttk
from PIL import Image,ImageTk
from tkinter import messagebox
import mysql.connector
# ==============variables==================
self.var_fname=StringVar
()
self.var_lname=StringVar
()
self.var_cnum=StringVar(
)
self.var_email=StringVar(
) self.var_ssq=StringVar()
self.var_sa=StringVar()
self.var_pwd=StringVar()
self.var_cpwd=StringVar(
) self.var_check=IntVar()
img3 =
Image.open("college_images/u.jpg") img3
= img3.resize((1710, 1150))
self.photoimg3 =
ImageTk.PhotoImage(img3) bg_img =
Label(self.root, image=self.photoimg3)
bg_img.place(x=0, y=0, width=1710, height=1050)
frame= Frame(self.root,bg="#F2F2F2",border=3)
frame.place(x=405,y=200,width=900,height=580)
#label1
fname =lb1= Label(frame,text="First Name:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2") fname.place(x=100,y=120)
#entry1
self.txtuser=ttk.Entry(frame,textvariable=self.var_fname,font=("times new
roman",18,"bold")) self.txtuser.place(x=103,y=145,width=270)
#label2
lname =lb1= Label(frame,text="Last Name:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2") lname.place(x=100,y=190)
#entry2
#label1
cnum =lb1= Label(frame,text="Contact No:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2")
#entry1
self.txtuser=ttk.Entry(frame,textvariable=self.var_cnum,font=("times new
roman",18,"bold")) self.txtuser.place(x=533,y=145,width=270)
#label2
email =lb1= Label(frame,text="Email:",font=("times new roman",18,"bold"),fg="#002B53",bg="#F2F2F2")
email.place(x=530,y=190)
#entry2
self.txtpwd=ttk.Entry(frame,textvariable=self.var_email,font=("times new
roman",18,"bold")) self.txtpwd.place(x=533,y=215,width=270)
#label1
ssq =lb1= Label(frame,text="Select Security Question:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2")
ssq.place(x=100,y=270)
#Combo Box1
self.combo_security = ttk.Combobox(frame,textvariable=self.var_ssq,font=("times new
roman",18,"bold"),state="readonly")
self.combo_security["values"]=("Select","Your Date of Birth","Your Nick Name","Your
Favorite Book") self.combo_security.current(0)
self.combo_security.place(x=103,y=295,width=270)
#label2
sa =lb1= Label(frame,text="Security Answer:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2") sa.place(x=100,y=340)
#entry2
self.txtpwd=ttk.Entry(frame,textvariable=self.var_sa,font=("times new
roman",18,"bold")) self.txtpwd.place(x=103,y=365,width=270)
#label1
pwd =lb1= Label(frame,text="Password:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2") pwd.place(x=530,y=270)
#entry1
self.txtuser=ttk.Entry(frame,textvariable=self.var_pwd,font=("times new
roman",18,"bold")) self.txtuser.place(x=533,y=295,width=270)
#label2
cpwd =lb1= Label(frame,text="Confirm Password:",font=("times new
roman",18,"bold"),fg="#002B53",bg="#F2F2F2") cpwd.place(x=530,y=340)
#entry2
self.txtpwd=ttk.Entry(frame,textvariable=self.var_cpwd,font=("times new
roman",18,"bold")) self.txtpwd.place(x=533,y=365,width=270)
loginbtn=Button(frame,text="Register",command=self.register_data,font=("times new
roman",18,"bold"),relief=RIDGE,fg="black")
loginbtn.place(x=103,y=470,width=270,height=35)
loginbtn=Button(frame,text="Login",font=("times new
roman",18,"bold"),command=self.ret_login,relief=RIDGE,fg="black")
loginbtn.place(x=533,y=470,width=270,height=35)
def ret_login(self):
self.root.destroy
()
# ======================function decaration===================
def register_data(self):
if (self.var_fname.get()=="" or self.var_lname.get()=="" or self.var_cnum.get()=="" or
self.var_email.get()=="" or self.var_ssq.get()=="Select" or self.var_sa.get()=="" or
self.var_pwd.get()=="" or self.var_cpwd.get()==""):
messagebox.showerror("Error","All Field Required!")
elif(self.var_pwd.get() != self.var_cpwd.get()):
messagebox.showerror("Error","Please Enter Password & Confirm Password are
Same!") elif(self.var_check.get()==0):
messagebox.showerror("Error","Please Check the Agree Terms and
Conditons!") else:
try:
# messagebox.showinfo("Successfully","Successfully Register!")
conn=mysql.connector.connect(host="localhost",user="root",password="swarnim0129",database=
"login
_schema",auth_plugin='mysql_native_passwor
d') mycursor = conn.cursor()
query=("select * from register where
email=%s") value=(self.var_email.get(),)
mycursor.execute(query,value)
row=mycursor.fetchone()
if row!=None:
messagebox.showerror("Error","User already exist,please try another
email") else:
mycursor.execute("insert into register values(%s,%s,%s,%s,%s,%s,%s)",(
self.var_fname.get(),
self.var_lname.get
Copyright © 2023-2024 Vidyavardhni’s Bhausaheb Vartak Polytechnic, Computer 70
Engineering
(),
self.var_cnum.get(
),
conn.commit()
conn.close()
messagebox.showinfo("Success","Successfully
Registerd!",parent=self.root) except Exception as es:
messagebox.showerror("Error",f"Due to: {str(es)}",parent=self.root)
FaceRecognition.py
from tkinter import *
from PIL import Image, ImageTk
import cv2
import mysql.connector
from datetime import datetime
import webbrowser
class Face_Recognition:
#new
def init (self, root):
self.root=root
self.root.geometry("1710x1150+0+0
") self.root.title("Training Panel")
img3 =
Image.open("./college_images/frec.png")
img3 = img3.resize((1710, 1050))
self.photoimg3 =
ImageTk.PhotoImage(img3) bg_img =
Label(self.root, image=self.photoimg3)
bg_img.place(x=0, y=58, width=1710, height=1010)
def face_recog(self):
def draw_boundray(img, classifier, scaleFactor, minNeighbors, color, text, clf):
gray_image=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
featuers=classifier.detectMultiScale(gray_image,scaleFactor,minNeighbors)
coord=[]
confidence=int((100*(1-predict/300)))
else:
cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),3)
cv2.putText(img,"Unknown Face",(x,y-5),cv2.FONT_HERSHEY_COMPLEX,0.8,(255,255,0),3)
return False
coord=[x,y,w,y]
return coord
r_pressed=False
def redirect_to_website():
webbrowser.open("https://sparkling-starship-e44032.netlify.app/") # Replace with your desired website URL
faceCascade =
cv2.CascadeClassifier("haarcascade_frontalface_default.xml") clf =
cv2.face.LBPHFaceRecognizer_create()
clf.read("clifi.xml")
videoCap = cv2.VideoCapture(0)
while True:
ret, img = videoCap.read()
img, coord = recognize(img, clf, faceCascade)
cv2.imshow("Face Detector", img)
key = cv2.waitKey(1)
mydata=[]
class Attendance:
img=Image.open("./college_images/scanning-
banner.png") img=img.resize((600,130))
self.photoimg=ImageTk.PhotoImage(img)
f_lbl =Label(self.root,image=self.photoimg)
# Variables
self.var_id=StringVar()
self.var_roll=StringVar()
self.var_name=StringVar
()
self.var_dep=StringVar()
self.var_time=StringVar()
self.var_date=StringVar()
img1 =
Image.open("./college_images/facialrecognition.png")
img1 = img1.resize((600,150))
self.photoimg1 =
ImageTk.PhotoImage(img1) f_lbl =
# bg img
img3 =
Image.open("./college_images/brainai.jpeg")
img3 = img3.resize((1710, 1050))
self.photoimg3 = ImageTk.PhotoImage(img3)
bg_img = Label(self.root,
image=self.photoimg3) bg_img.place(x=0,
y=130, width=1710, height=1050)
title_lbl=Label(bg_img,text="Attendance
Records",font=("verdana",35,"bold"),bg="white",fg="green")
title_lbl.place(x=0,y=0,width=1710,height="45")
main_frame=Frame(bg_img,bd=2,bg="white")
main_frame.place(x=10,y=75,width=
1680,height=825)
left_frame=LabelFrame(left_side_frame,bd=2,relief=RIDGE,text="Student Attendance
Details",font=("verdana",20,"bold"),fg="navyblue",bg="white")
left_frame.place(x=0,y=135,width=813,height=300)
#Student id
studentId_label = Label(left_frame,text="Std-
ID:",font=("verdana",18,"bold"),fg="black",bg="white")
studentId_label.grid(row=0,column=0,padx=5,pady=5,sticky=W)
studentId_entry =
ttk.Entry(left_frame,textvariable=self.var_id,width=20,font=("verdana",16,"bold"))
#Student Roll
student_roll_label = Label(left_frame,text="Roll.No:",font=("verdana",18,"bold"),fg="black",bg="white")
student_roll_label.grid(row=0,column=2,padx=5,pady=5,sticky=W)
student_roll_entry = ttk.Entry(left_frame,textvariable=self.var_roll,width=20,font=("verdana",16,"bold"))
student_roll_entry.grid(row=0,column=3,padx=5,pady=5,sticky=W)
student_name_entry =
ttk.Entry(left_frame,textvariable=self.var_name,width=20,font=("verdana",16,"bold"))
student_name_entry.grid(row=1,column=1,padx=5,pady=5,sticky=W)
#time
time_label =
Label(left_frame,text="Time:",font=("verdana",18,"bold"),fg="black",bg="white")
time_label.grid(row=1,column=2,padx=5,pady=5,sticky=W)
time_entry =
ttk.Entry(left_frame,textvariable=self.var_time,width=20,font=("verdana",16,"bold"))
time_entry.grid(row=1,column=3,padx=5,pady=5,sticky=W)
#Date
date_label =
Label(left_frame,text="Date:",font=("verdana",18,"bold"),fg="black",bg="white")
date_label.grid(row=2,column=0,padx=5,pady=5,sticky=W)
date_entry =
ttk.Entry(left_frame,textvariable=self.var_date,width=20,font=("verdana",16,"bold"))
date_entry.grid(row=2,column=1,padx=5,pady=5,sticky=W)
#Attendance
student_attend_label = Label(left_frame,text="Attend-
status:",font=("verdana",18,"bold"),fg="black",bg="white")
student_attend_label.grid(row=2,column=2,padx=5,pady=5,sticky=W)
attend_combo=ttk.Combobox(left_frame,textvariable=self.var_attend,width=19,font=("verdana",16,"bol
d"),stat e="readonly")
attend_combo["values"]=("Status","Present","Absent")
attend_combo.current(0)
attend_combo.grid(row=2,column=3,padx=5,pady=5,s
ticky=W)
#Button Frame
btn_frame = Frame(left_side_frame,bd=2,bg="white",relief=RIDGE)
btn_frame.place(x=5,y=320,width=805,height=110)
#Import button
save_btn=Button(btn_frame,text="Import
CSV",width=19,command=self.importCsv,font=("verdana",19,"bold"),fg="navyblue",bg="navyblue")
save_btn.grid(row=0,column=0,padx=22,pady=10,sticky=W)
#Export button
update_btn=Button(btn_frame,text="Export
CSV",command=self.exportCsv,width=19,font=("verdana",19,"bold"),fg="navyblue",bg="navyblue")
#Update button
del_btn=Button(btn_frame,text="Update",width=19,command=self.update_data,font=("verdana",19,"bol
d"),fg= "navyblue",bg="navyblue")
del_btn.grid(row=1,column=0,padx=22,pady=10,sticky=W)
reset_btn=Button(btn_frame,text="Reset",width=19,command=self.reset_data,font=("verdana",19,"bold
"),fg="n avyblue",bg="navyblue")
reset_btn.grid(row=1,column=1,padx=22,pady=10,sticky=W)
table_frame = LabelFrame(right_frame,bd=2,bg="white",relief=RIDGE,text="Search
System",font=("verdana",20,"bold"),fg="navyblue")
table_frame.place(x=5,y=5,width=805,height=445)
self.attendanceReport = ttk.Treeview(table_frame,column=("Student_id","Class","Roll-
No","Name","Time","Date","Attend"),xscrollcommand=scroll_x.set,yscrollcommand=
scroll_y.set)
scroll_x.pack(side=BOTTOM,fill=X)
scroll_y.pack(side=RIGHT,fill=Y)
scroll_x.config(command=self.attendanceReport.xview)
scroll_y.config(command=self.attendanceReport.yview)
self.attendanceReport.heading("Student_id",text="Stude
nt_id") self.attendanceReport.heading("Roll-
No",text="Roll-No")
self.attendanceReport.heading("Class",text="Class")
self.attendanceReport.heading("Name",text="Student-
Name")
self.attendanceReport.heading("Time",text="Time")
self.attendanceReport.heading("Date",text="Date")
self.attendanceReport.heading("Attend",text="Attend-
status") self.attendanceReport["show"]="headings"
self.attendanceReport.pack(fill=BOTH,expand=1)
self.attendanceReport.bind("<ButtonRelease>",self.get_cursor_left)
def importCsv(self):
global
mydata
mydata.clear
()
fln=filedialog.askopenfilename(initialdir=os.getcwd(),title="Open Csv",filetypes=(("CSV file","*csv"),( "All
File","*.*")),parent=self.root)
with open(fln) as myfile:
csvread=csv.reader(myfile,delimiter
=",") for i in csvread:
mydata.append(i)
self.fetchData(mydata)
def
exportCsv(self):
try:
if len(mydata)<1:
messagebox.showerror("No Data","No Data found to
export",parent=self.root) return False
fln=filedialog.asksaveasfilename(initialdir=os.getcwd(),title="Open Csv",filetypes=(("CSV file","*csv"),( "All
File","*.*")),parent=self.root)
with open(fln,mode="w",newline="") as
myfile:
exp_write=csv.writer(myfile,delimiter
=",") for i in mydata:
exp_write.writerow(i)
messagebox.showinfo("Data export","Your data exported to "+os.path.basename(fln)+"
Successfully") except Exception as es:
messagebox.showerror("Error", f"Due to:{str(es)}", parent=self.root)
def reset_data(self):
self.var_id.set("")
self.var_roll.set("")
self.var_name.set("")
self.var_time.set("")
self.var_date.set("")
self.var_attend.set("Statu
s")
def update_data(self):
if self.var_id.get()=="" or self.var_roll.get=="" or self.var_name.get()=="" or
self.var_time.get()=="" or self.var_date.get()=="" or
self.var_attend.get()=="Status":
messagebox.showerror("Error","Please Fill All Fields are
Required!",parent=self.root) else:
try:
Update=messagebox.askyesno("Update","Do you want to Update this Student
Attendance!",parent=self.root) if Update > 0:
conn = mysql.connector.connect(host="localhost", user="root",
password="swarnim0129",database="face_recognizer",
auth_plugin='mysql_native_password')
mycursor = conn.cursor()
mycursor.execute("update attendance
set
std_id=%s,std_roll_no=%s,std_name=%s,std_time=%s,std_date=
%s,std_attendance=%s where std_id=%s",(
self.var_id.get(),
self.var_roll.get(),
self.var_name.get(
),
self.var_time.get(),
self.var_date.get(),
self.var_attend.get
(), self.var_id.get()
))
else:
if not Update:
return
messagebox.showinfo("Success","Successfully Updated!",parent=self.root)
conn.commit()
self.fetch_data()
conn.close()
except Exception as es:
messagebox.showerror("Error",f"Due to: {str(es)}",parent=self.root)
def fetch_data(self):
conn = mysql.connector.connect(host="localhost", user="root",
password="swarnim0129",database="face_recognizer", auth_plugin='mysql_native_password')
mycursor = conn.cursor()
if len(data)!= 0:
self.attendanceReport.delete(*self.attendanceReport.get_childr
en()) for i in data:
self.attendanceReport.insert("",END,values
=i) conn.commit()
conn.close()
ALGORITHM
FACE-FLEX
Algorithm
It uses this formula and based on this formula it recognizes the face by building
Certain confidence and based on that confidence it tracks down the image.
This function will take the images from a folder and train the images using LBPH
algorithm and generate the classifier file (clifi). Which contains the binary data of the
trained images
This function reads the classifier file and detects the face according to the binary
data generated in the file and is released after hitting enter key to free up the
memory as well and to reduce the load on the cpu/processor
If the confidence generated by detecting the face is greater than 88 (it is used to
mark the attendance when it is more accurate) then only it will show the
student details above the camera frame else It will show unknown face.
TESTING
FACE-FLEX
7.1Introduction:
Once source code has been generated, software must be tested to uncover
(and correct) as manyerrors as possible before delivering to the customer.
Our goal is to design a series of test casesthat have a high likelihood of
finding errors. To uncover the errors software techniques are used. These
techniques provide systematic guidance for designing test that:
1) Exercise the internal logic of software components.
2) Exercise the input and output domains of the program to uncover
7.2Testing Methodologies:
A strategy for software testing must accommodate low-level test that are
necessary to verify that a small source code segment has been correctly
implemented as well as high level tests that validate major system functions
again customer requirements. A strategy must provide guidance for the
practitioner and a set of milestones for the manager. Because the step of
the test strategyoccur at a time and deadline pressure begins to rise,
progress must be measurable, and problems must surface as early as
possible. Following testing techniques are well known and the same
strategy is adopted during this project testing.
7.2.1 Unit testing
7.2.2 System testing
7.2.3 Performance testing
2. System Testing:
3. Performance Testing:
The cost estimation for a face detection attendance system can vary depending on
several factors such as the size and complexity of the system, the features and
functionalities required, the technology and tools used, and the development
team's location and hourly rate.
Technology and tools: The cost of technology and tools used in building the
system such as server infrastructure, cloud services, software licenses, and
development tools should be considered.
Future Work:
In the future comings the web application will be made location specific
like the QR and the attendance marking will bound by the location that is
only the range of classroom. Anyone who isalso not just a step outside from
the classroom would not be able to mark Attendance using the location
API.
Based on this Concept we can create A website which handles all
the academic related work such as notes management and doubt
solver
In future the feature will be updated which will display and assign roles
for each of the teacher andstaff working.
http://www.academia.edu/
http://www.stackoverflow.com/
http://www.iproject.com