E-Attendance System with Face Recognition
E-Attendance System with Face Recognition
On
BACHELOR OF TECHNOLOGY
IN
BY
(Associative Professor)
2019-2023
VAAGDEVI COLLEGE OF ENGINEERING
(Autonomous, Affiliated to JNTUH, NAAC ‘A’ Grade and NBA Accredited)
CERTIFICATE
This is to certify that the project work entitled “E-Attendance System using Face
Recognition” is a bonafide work carried out by
and Mr. P. Pranay (19641A05F2) in partial fulfillment of the requirements for the
award of degree Bachelor of technology in Computer Science and Engineering from
Vaagdevi college of Engineering (Autonomous) during the academic year 2022-2023.
Project Guide
DECLARATION
We declare that the work reported in the project entitled “E-Attendance System using
Face Recognition” is a record of work done by us in the partial fulfillment for the award
of degree Bachelor of Technology in Computer Science and Engineering, Vaagdevi
college of Engineering (Autonomous), Affiliated to JNTUH, NAAC ‘A’ Grade, under
the guidance of Mr, Salim Amirali Jiwani Assistant Professor, CSE department. We
hereby declare that this project work bears no resemblance to any other project submitted
at Vaagdevi College of Engineering or any other university/college for the award of the
degree.
The development of the project though it was an arduous task, it has been made by the
help of many people. We are pleased to express our thanks to the people whose
suggestions, comments, criticisms greatly encouraged us in betterment of the project.
We would like to express our sincere gratitude and indebtedness to my project Guide Mr.
Salim Amirali Jiwani , Assistant Professor, for his valuable suggestions and interest
throughout the course of this project.
We would like to express our sincere thanks and profound gratitude to Dr. K. Prakash,
principal of Vaagdevi College of Engineering, for his support, guidance and
encouragement in the course of our project.
We are also thankful to the Head of the Department Dr. N. Satyawathi Associative
Professor for providing excellent infrastructure and a nice atmosphere for completing this
project successfully.
We are highly thankful to the Project Coordinators for their valuable suggestions,
encouragement and motivations for completing this project successfully.
Finally, we would like to take this opportunity to thank our families for their support
through the work. We sincerely acknowledge and thank all those who gave directly or
indirectly their support in completion of this work.
Abstract............................................................................................................i
List of Acronyms…….....................................................................................iv
CHAPTER I
INTRODUCTION 01 - 06
1.1 Objectives 02
1.3 Methodologies 03
1.4 Contributions 04 - 05
CHAPTER II
LITERATURE SURVEY 07 - 13
CHAPTER III
SYSTEM ANALYSIS AND DESCRIPTION 14 - 20
CHAPTER IV
CHAPTER V
IMPLEMENTATION 22 - 23
5.1 Algorithm 22
5.2 Flowchart 22
5.3 Dataset 23
CHAPTER VI
TESTING 24 - 28
CHAPTER VII
7.1 Observations 29
7.2 Result Analysis 29 -31
7.3 Limitations 32
7.4 Future works & concluding remarks 33
7.4.1 Conclusion 33
7.4.2 Future Enhancement 33
REFERENCES 34
APPENDIX 35 - 51
ABSTRACT
i
LIST OF FIGURES
Fig.5.1 Flowchart 22
Fig.7.4 Click on the attendance which shows at the left side of the interface 31
ii
LIST OF TABLES
iii
LIST OF ACRONYMS
iv
CHAPTER I
INTRODUCTION
1
number of features (Shape, Colour, LBP, wavelet, Auto-Correlation) of the face. Faces
are recognized using Euclidean distance and k-nearest neighbor algorithms. Better
accuracy is attained in results as the system takes into account the changes that occur in
the face over the period of time and employs suitable learning algorithms. The system is
tested for various use cases. We consider a specific area such as classroom attendance
for the purpose of testing the accuracy of the system. The metric considered is the
percentage of the recognized faces per total number of tested faces of the same person.
The system is tested under varying lighting conditions, various facial expressions,
presence of partial faces (in densely populated classrooms) and presence or absence of
beard and spectacles. An increased accuracy (nearly 100%) is obtained in most of the
cases considered.
1.1 Objectives
2
1.3 Methodologies
In order to obtain the attendance, positions and face images in lecture, we
proposed the E- Attendance System using Face Recognition in the classroom lecture. The
system estimates the attendance and positions of each student by continuous observation
and recording. Current work is based on the method to obtain the different weights of
each focused seat.
3
camera positioned at the door which senses anyone entering or exiting the classroom. The
camera is trained in such a way that it differentiates shadows and photos.
1. Feature-Based approach
Feature-Based approach
The Feature-based approach also known as local face recognition system, used in
pointing the key features of the face.
As group, we managed to divide the work between us as shown in (Table 1). We were
collaborating and meeting with each other, in order to try our best to work on the project
despite what is happening.
4
1.5 Layout of the project
Camera
Camera: The camera is the only hardware component required to capture live video feed
of class.
Vision Acquisition: This module allows image to be captured by camera into LabVIEW
for programming. It includes IMAQ submodules such as IMAQ Create, IMAQdx Open,
IMAQdx Grab. They all combine to provide Continuous Acquisition of video feed from
camera module.
5
Image to Grayscale: This process is performed using IMAQ ExtractSingleColorPlane
VI to convert a 32/16bit image to 8bit image. This is a requirement for our pattern
matching algorithm to work completely.
Pattern Extraction: This is included in Vision Assistant VI which deals with our face
recognition algorithm. Pattern Extraction is feature in which the image inputted features
are compared using Pattern Matching Algorithm.
Feature Extraction: This feature is used to extract important features out of image. It
compares them with templates, saves in database and provides a score of comparison.
Find Match in database: Our database has preserved templates or images of students
which we aim to recognize and mark attendance. This database can be updated or
appended according to requirement. This database is used for comparison with extracted
feature of image to confirm a successful hit.
Update Attendance [Link]: If match is found our algorithm updates the attendance
of user corresponding to his/her name in excel file of format .xlsx. If not, the system
marks absent in front of his/her name in the same excel file.
CHAPTER II
LITERATURE SURVEY
In the face detection and recognition system, the process flow is initiated by being able to
detect the facial features from a camera or a picture store in a memory. The algorithm
processes the image captured and identifies the number of faces in the image by
6
analyzing from the learned pattern and compare them to filter out the rest. This image
processing uses multiple algorithm that takes facial features and compare them with
known database. The motivation behind this project is to simplify the means by which
attendance is taken during lectures and how much time it takes. The use of ID cards or
manually calling out attendance and writing it down on sheets is not productive and
efficient. This system will detect the number of faces on the class and will also identify
them from the store database. With the face detection and recognition system in place, it
will be easy to tell if a student is actually present in the classroom or not.
PROJECT # 1
This is a project done by students as a final year project at Kingston University London in
2018.
The system will be presented an image either via camera or from memory and it
must detect the number of faces on it automatically. After identifying faces, the system
should crop the faces from the image and store them in memory for image recognition
which will be done in the second step. The system should be able to automatically count
the number of faces detected on the image. The second step will be the recognition part
where the system will be able to match faces from the stored dataset and compare it to the
input data from the first step. A software will be used for this system which automatically
sorts out the faces. The software will be inter-active so to facilitate interaction between
multiple tasks as required. Because the system has two steps, the second phase of the
system will involve the training of images on a dataset that are to be used for recognition.
7
Fig 2.1: BLOCK DIAGRAM OF PREVIOUS PROJECT #1
Technology Used
The key algorithms are Viola-Jones for face detection and Hidden Markov Model
with SVD.
8
The implementation of The Viola-Jones algorithm is available on softwares like
MATLAB, OpenCV and Web Browsers (using adobe flash).
The existing implementation of the Hidden Markov Model with SVD for face
recognition are available on MATLAB, C++ and OpenCV libraries.
PROJECT #2
This is a project done by students as a final year project at University of Nairobi in 2012.
The system will comprise of two modules. The first module a.k.a face detector is
a mobile component, which is basically a camera that captures student faces and stores
them in a file using computer vision face detection algorithms and face extraction
techniques. The second module is a desktop application that does face recognition of the
captured images (faces) in the file, marks the students register and then stores the results
in a database for future analysis.
9
Fig 2.2: BLOCK DIAGRAM OF PREVIOUS PROJECT #2
Technology Used
The following tools will be used in the implementation of the designed system.
They’ve been divided in to two categories; Mobile and Desktop tools.
Mobile Tools
The face detection module will use OpenCV library for implementation by use of
the frontal Haar Cascade face detector in either Android studio.
10
Android Studio/ Eclipse IDE - Android Studio is the official IDE for Android
application development, based on IntelliJ IDEA.
Desktop Tools
EmguCV Library - EmguCV is a cross platform .Net wrapper to the OpenCV image
processing library. OpenCV/EmguCV uses a type of face detector called a Haar Cascade.
The Haar Cascade is a classifier (detector) trained on thousands of human faces.
Visual Studio - Visual Studio is able to build and run the solution examples after a
proper configuration of EmguCV. The desktop software will implement the two sub-
systems (Training set manager and Face recognizer) together with face detector in
windows form.
PROJECT # 3
This is a project done by students as a final year project at Universiti Tunku in 2018.
11
Fig 2.3: BLOCK DIAGRAM OF PREVIOUS PROJECT #3
The project is completely built in MATLAB with OpenCV libraries implemented in it.
Our project is different than all the previous projects made and mentioned above.
They have purely used the core of machine vision to implement a face detection
mechanism. None of the abovementioned projects have realized the power of LabVIEW
programming and LabVIEW Vision modules in which not only pattern matching but
other machine vision algorithms like edge tracking, geometric matching can be
implemented with ease. Though the general mechanism and flow of events is similar in
12
above projects and our current project however, the mechanism of face detection is
completely unique and different.
Local Usage in ✓ ✓ ✓
schools
Data Saving in ✓ ✓
Record
(Monitoring)
13
CHAPTER III
3. SYSTEM ANALYSIS AND DECRIPTION
1) Biometric scan
a. College ID cards are fitted with RFID chips which are scanned by readers
installed in each classroom.
b. The cards are scanned before each class to mark the student’s attendance.
c. The server is updated every ten minutes.
d. Every teaching faculty gets a list of all the students who were present after
every class is over.
e. An online portal allows access to students to view their current attendance.
3) Existing algorithms
14
3.2 Proposed system:
This section describes the software algorithm for the system. The algorithm consists of
the following steps
Image acquisition
Histogram normalization
Noise removal
Skin classification
Face detection
15
Face recognition
Attendance
In the first step image is captured from the camera. There are illumination effects
in the captured image because of different lighting conditions and some noise which is to
be removed before going to the next steps. Histogram normalization is used for contrast
enhancement in the spatial domain. Median filter is used for removal of noise in the
image. There are other techniques like FFT and low pass filter for noise removal and
smoothing of the images but median filter gives good results.
TECHINICAL FEASIBILITY:
Evaluating the technical feasibility is the trickiest part of a feasibility study. This
is because, at this point in time, not too many detailed design of the system, making it
difficult to access issues like performance, costs on (on account of the kind of technology
to be deployed) etc.
Before commencing the project, we have to be very clear about what are the
Technologies that are to be required for the development of the new system.
ii) Find out whether the organization currently possesses the required
technologies:
Is the required technology available with the organization?
For instance –
“Will the current printer be able to handle the new reports and forms required for
the new system?”
16
OPERATIONAL FEASIBILITY:
Proposed projects are beneficial only if they can be turned into information systems
that will meet the organizations operating requirements. Simply stated, this test of
feasibility asks if the system will work when it is developed and installed. Are there
major barriers to Implementation? Here are questions that will help test the operational
feasibility of a project:
Is there sufficient support for the project from management from users? If the current
system is well liked and used to the extent that persons will not be able to see
reasons for change, there may be resistance.
Are the current business methods acceptable to the user? If they are not, Users may
welcome a change that will bring about a more operational and useful systems.
Have the user been involved in the planning and development of the project?
In the existing manual system, the new system was considered to be operational feasible.
ECONOMIC FEASIBILITY:
A simple economic analysis which gives the actual comparison of costs and
benefits are much more meaningful in this case. In addition, this proves to be a useful
point of reference.
17
THE INCREMENTAL, ITERATIVE SOFTWARE ENGINEERING LIFE
CYCLE:
When we defining and constructing credit card validation systems will uncover
many requirements that may be difficult at outset. Instead knowledge of the system and
requirements will grow as work progress the whole software engineering process is
designed to uncover details and incompatibilities in the requirements that may not be
obvious to customer and bankers at outset.
ADVANTAGES:
DISADVANTAGES:
1. If the requirements are gathered are inaccurate then the final product is inaccurate
and the error is known in the final phase of the model. Any sort of errors that
cannot be detected in any previous phase.
2. For long, object-oriented, complex and ongoing projects it’s a poor model.
3. This model has high risks.
Analysis
Requirements
18
specification
Design
Fig 3.1: Waterfall Lifecycle Model
PROTOTYPE MODEL:
In this model the requirements are gathered firstly, and the prototype is deployed
according to the requirements. This prototype is a quick design which goes through the
coding, design and testing. The phases are not done in detail. By seeing this prototype the
client feels like a real system, so that the client understands the entire requirements of the
systems.
ADVANTAGES:
DISADVANTAGES:
19
2. The model is implemented firstly and then errors are evaluated later which
becomes a complex process.
3. The model is also known as throw-away prototype.
SYSTEM DESIGN
ER-DIAGRAM
20
21
CHAPTER IV
4. SOFTWARE REQUIREMENT SPECIFICATIONS
● scikit-learn: Simple and efficient tools for data mining and data analysis.
● scipy: a free and open source library for scientific and technical computing.
a. Reading and writing from an SQLite database is often faster than reading and writing
individual files from disk
b. The application only has to load the data it needs, rather than reading the entire file and
holding a complete parse in memory.
d. SQL queries are many times smaller than the equivalent procedural code
22
e. SQLite database content can be viewed using a wide variety third-party tools.
CHAPTER V
5. IMPLEMENTATION
5.1 Algorithm
We have imported our code in python command window. The project requirement
overall code has been shown in appendix.
5.2 Flowchart
Models
Yes
Classification Face
stage ?
Yes No
Input Text Face
images candida
LBP
No
(3x3 blocks) Non Face Face
Non Face
24
Figure 5.3 – User Interface and Output Screen
CHAPTER VI
TESTING
One is Black-Box testing – the specified function that a product has been
designed to perform, tests can be conducted that demonstrate each function is fully
operated.
25
performs according to specifications and all internal components have been
adequately exercised.
White box and Black box testing methods have been used to test this package.
All the loop constructs have been tested for their boundary and intermediate conditions.
The test data was designed with a view to check for all the conditions and logical
decisions. Error handling has been taken care of by the use of exception handlers.
Testing Strategies:
Unit Testing:
Unit testing focuses verification effort on the smallest unit of software design –
the module. The unit test is always white box oriented. The tests that occur as part of
unit testing are testing the module interface, examining the local data structures, testing
the boundary conditions, executing all the independent paths and testing error-handling
paths.
Integration Testing:
26
Integration testing is a systematic technique for constructing the program structure
while at the same time conducting tests to uncover errors associated with interfacing.
Scope of testing summarizes the specific functional, performance, and internal design
characteristics that are to be tested. It employs top-down testing and bottom-up testing
methods for this case.
The purpose of any security testing method is to ensure the robustness of a system
in the face of malicious attacks or regular software failures. White box testing is
performed based on the knowledge of how the system is implemented. White box testing
includes analyzing data flow, control flow, information flow, coding practices, and
exception and error handling within the system, to test the intended and unintended
software behavior. White box testing can be performed to validate whether code
implementation follows intended design, to validate implemented security functionality,
and to uncover exploitable vulnerabilities.
White box testing requires access to the source code. Though white box testing
can be performed any time in the life cycle after the code is developed, it is a good
practice to perform white box testing during the unit testing phase.
White box testing requires knowing what makes software secure or insecure, how
to think like an attacker, and how to use different testing tools and techniques. The first
step in white box testing is to comprehend and analyze source code, so knowing what
makes software secure is a fundamental requirement. Second, to create tests that exploit
software, a tester must think like an attacker. Third, to perform testing effectively, testers
need to know the different tools and techniques available for white box testing. The three
requirements do not work in isolation, but together.
27
outcomes should be and not how the program arrives at those outputs. The tester does not
ever examine the programming code and does not need any further knowledge of the
program other than its specifications.
The test is unbiased because the designer and the tester are independent of each
other.
The tester does not need knowledge of any specific programming languages.
The test is done from the point of view of the user, not the designer.
Test cases can be designed as soon as the specifications are complete.
System Testing :
System testing validates software once it has been incorporated into a larger
system. Software is incorporated with other system elements and a series of system
integration and validation tests are conducted. System testing is actually a series of
different test whose primary purpose is to fully exercise the computer- based system.
Once the system has been developed it has to be tested. In the present system we
have to take care of valid property and assessment numbers i.e. there should not exist any
duplicate number in each case. Care should be taken that the appropriate data is retrieved
in response to the queries.
VALIDATION:
The terms verification and validations are used interchangeably we will describe
both these methods. Verification is the process of determining whether or not the
products of given phase of software development fulfill the specifications established in
the previous phase. These activities include proving and reviews.
28
TABLE 6.1: TEST CASES
29
4 Update Multiple Update Update Pass
attendance for faces from Attendance Attendance
multiple a live video for all faces for all
people at once stream detected faces
detected
CHAPTER VII
7.1 Observations
The database before the attendance is as shown in fig 7.1(since there is no data
available in the excel sheet).
30
Figure 7.1 – Database Before Attendance
After registration has been completed, a faculty or any person who has authority to take
attendance should click on the Take Attendance on the left side of the user interface
shown in the Fig.7.3. Then we were successfully able to detect face using camera and
update the present students in a excel file as shown in Figure 7.4.
31
Figure 7.4 – Click on the Take Attendance which shows at the left side of the
interface
7.3 Limitations
32
7.4 Future works & concluding remarks
7.4.1 Conclusion
33
RFERENCES
The following books were referred during the analysis and execution phase of the
project.
References
[1]A Study of Various Face Detection Methods , [Link] Gupta1 , Mr. Dipesh
Sharma2,ijarcce volume 3[Link] CCE7G%2
0%20a%20varsha%20A%20Study%20of%20Vario us%20F
[2]Face Recognition Based on HOG and Fast PCA Algorithm Xiang-Yu Li(&) and Zhen-
Xian Lin.
[3]Attendance System Using Face Recognition and Class Monitoring System, Arun
Katara1, Mr. Sudesh2, V.Kolhe3[Link] Volume_
5_Issues/February_17_Volume_5_Issue_2/14895658 66_ [Link]
[4] G. Yang and T. S. Huang, “Human face detection in complex background,” Pattern
Recognition Letter, vol. 27, no.1, pp. 53-63, 1994.
[5] C. Kotropoulos and I. Pitas, “Rule-based face detection in frontal views,” Proc. Int’l
Conf. Acoustics, Speech and Signal Processing, vol. 4, pp. 2537-2540, 1997.
[6] Xinjun Ma, Hongqiao Zhang, XinZang, “A face detection algorithm based on
modified skin-color model”, CCC, vol. 1, pp. 3896-3900, IEEE, 2013
34
APPENDIX
############################################# IMPORTING
################################################
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox as mess
import [Link] as tsd
import cv2,os
import csv
import numpy as np
from PIL import Image
import pandas as pd
import datetime
import time
############################################# FUNCTIONS
################################################
def assure_path_exists(path):
dir = [Link](path)
if not [Link](dir):
[Link](dir)
########################################################################
##########
def tick():
time_string = [Link]('%H:%M:%S')
35
[Link](text=time_string)
[Link](200,tick)
########################################################################
###########
def contact():
mess._show(title='Contact us', message="Please contact us on :
'xxxxxxxxxxxxx@[Link]' ")
########################################################################
###########
def check_haarcascadefile():
exists = [Link]("haarcascade_frontalface_default.xml")
if exists:
pass
else:
mess._show(title='Some file missing', message='Please contact us for help')
[Link]()
########################################################################
###########
def save_pass():
assure_path_exists("TrainingImageLabel/")
exists1 = [Link]("TrainingImageLabel\[Link]")
if exists1:
tf = open("TrainingImageLabel\[Link]", "r")
key = [Link]()
else:
[Link]()
new_pas = [Link]('Old Password not found', 'Please enter a new password
below', show='*')
if new_pas == None:
mess._show(title='No Password Entered', message='Password not set!! Please try
again')
36
else:
tf = open("TrainingImageLabel\[Link]", "w")
[Link](new_pas)
mess._show(title='Password Registered', message='New password was registered
successfully!!')
return
op = ([Link]())
newp= ([Link]())
nnewp = ([Link]())
if (op == key):
if(newp == nnewp):
txf = open("TrainingImageLabel\[Link]", "w")
[Link](newp)
else:
mess._show(title='Error', message='Confirm new password again!!!')
return
else:
mess._show(title='Wrong Password', message='Please enter correct old password.')
return
mess._show(title='Password Changed', message='Password changed successfully!!')
[Link]()
########################################################################
###########
def change_pass():
global master
master = [Link]()
[Link]("400x160")
[Link](False,False)
37
[Link]("Change Password")
[Link](background="white")
lbl4 = [Link](master,text=' Enter Old Password',bg='white',font=('times', 12, ' bold
'))
[Link](x=10,y=10)
global old
old=[Link](master,width=25 ,fg="black",relief='solid',font=('times', 12, ' bold
'),show='*')
[Link](x=180,y=10)
lbl5 = [Link](master, text=' Enter New Password', bg='white', font=('times', 12, '
bold '))
[Link](x=10, y=45)
global new
new = [Link](master, width=25, fg="black",relief='solid', font=('times', 12, ' bold
'),show='*')
[Link](x=180, y=45)
lbl6 = [Link](master, text='Confirm New Password', bg='white', font=('times', 12, '
bold '))
[Link](x=10, y=80)
global nnew
nnew = [Link](master, width=25, fg="black", relief='solid',font=('times', 12, ' bold
'),show='*')
[Link](x=180, y=80)
cancel=[Link](master,text="Cancel",
command=[Link] ,fg="black" ,bg="red" ,height=1,width=25 , activebackground
= "white" ,font=('times', 10, ' bold '))
[Link](x=200, y=120)
save1 = [Link](master, text="Save", command=save_pass, fg="black",
bg="#3ece48", height = 1,width=25, activebackground="white", font=('times', 10, ' bold
'))
[Link](x=10, y=120)
[Link]()
38
########################################################################
#############
def psw():
assure_path_exists("TrainingImageLabel/")
exists1 = [Link]("TrainingImageLabel\[Link]")
if exists1:
tf = open("TrainingImageLabel\[Link]", "r")
key = [Link]()
else:
new_pas = [Link]('Old Password not found', 'Please enter a new password
below', show='*')
if new_pas == None:
mess._show(title='No Password Entered', message='Password not set!! Please try
again')
else:
tf = open("TrainingImageLabel\[Link]", "w")
[Link](new_pas)
mess._show(title='Password Registered', message='New password was registered
successfully!!')
return
password = [Link]('Password', 'Enter Password', show='*')
if (password == key):
TrainImages()
elif (password == None):
pass
else:
mess._show(title='Wrong Password', message='You have entered wrong password')
39
########################################################################
##############
def clear():
[Link](0, 'end')
res = "1)Take Images >>> 2)Save Profile"
[Link](text=res)
def clear2():
[Link](0, 'end')
res = "1)Take Images >>> 2)Save Profile"
[Link](text=res)
########################################################################
###############
def TakeImages():
check_haarcascadefile()
columns = ['SERIAL NO.', '', 'ID', '', 'NAME']
assure_path_exists("StudentDetails/")
assure_path_exists("TrainingImage/")
serial = 0
exists = [Link]("StudentDetails\[Link]")
if exists:
with open("StudentDetails\[Link]", 'r') as csvFile1:
reader1 = [Link](csvFile1)
for l in reader1:
serial = serial + 1
serial = (serial // 2)
40
[Link]()
else:
with open("StudentDetails\[Link]", 'a+') as csvFile1:
writer = [Link](csvFile1)
[Link](columns)
serial = 1
[Link]()
Id = ([Link]())
name = ([Link]())
if (([Link]()) or (' ' in name)):
cam = [Link](0)
harcascadePath = "haarcascade_frontalface_default.xml"
detector = [Link](harcascadePath)
sampleNum = 0
while (True):
ret, img = [Link]()
gray = [Link](img, cv2.COLOR_BGR2GRAY)
faces = [Link](gray, 1.3, 5)
for (x, y, w, h) in faces:
[Link](img, (x, y), (x + w, y + h), (255, 0, 0), 2)
# incrementing sample number
sampleNum = sampleNum + 1
# saving the captured face in the dataset folder TrainingImage
[Link]("TrainingImage\ " + name + "." + str(serial) + "." + Id + '.' +
str(sampleNum) + ".jpg",
gray[y:y + h, x:x + w])
# display the frame
[Link]('Taking Images', img)
# wait for 100 miliseconds
if [Link](100) & 0xFF == ord('q'):
41
break
# break if the sample number is morethan 100
elif sampleNum > 100:
break
[Link]()
[Link]()
res = "Images Taken for ID : " + Id
row = [serial, '', Id, '', name]
with open('StudentDetails\[Link]', 'a+') as csvFile:
writer = [Link](csvFile)
[Link](row)
[Link]()
[Link](text=res)
else:
if ([Link]() == False):
res = "Enter Correct name"
[Link](text=res)
########################################################################
################
def TrainImages():
check_haarcascadefile()
assure_path_exists("TrainingImageLabel/")
recognizer = cv2.face_LBPHFaceRecognizer.create()
harcascadePath = "haarcascade_frontalface_default.xml"
detector = [Link](harcascadePath)
faces, ID = getImagesAndLabels("TrainingImage")
try:
[Link](faces, [Link](ID))
42
except:
mess._show(title='No Registrations', message='Please Register someone first!!!')
return
[Link]("TrainingImageLabel\[Link]")
res = "Profile Saved Successfully"
[Link](text=res)
[Link](text='Total Registrations till now : ' + str(ID[0]))
########################################################################
####################3
def getImagesAndLabels(path):
# get the path of all the files in the folder
imagePaths = [[Link](path, f) for f in [Link](path)]
# create empth face list
faces = []
# create empty ID list
Ids = []
# now looping through all the image paths and loading the Ids and the images
for imagePath in imagePaths:
# loading the image and converting it to gray scale
pilImage = [Link](imagePath).convert('L')
# Now we are converting the PIL image into numpy array
imageNp = [Link](pilImage, 'uint8')
# getting the Id from the image
ID = int([Link](imagePath)[-1].split(".")[1])
# extract the face from the training image sample
[Link](imageNp)
[Link](ID)
return faces, Ids
43
########################################################################
###################
def TrackImages():
check_haarcascadefile()
assure_path_exists("Attendance/")
assure_path_exists("StudentDetails/")
for k in tv.get_children():
[Link](k)
msg = ''
i=0
j=0
recognizer = [Link].LBPHFaceRecognizer_create() #
[Link]()
exists3 = [Link]("TrainingImageLabel\[Link]")
if exists3:
[Link]("TrainingImageLabel\[Link]")
else:
mess._show(title='Data Missing', message='Please click on Save Profile to reset
data!!')
return
harcascadePath = "haarcascade_frontalface_default.xml"
faceCascade = [Link](harcascadePath);
cam = [Link](0)
font = cv2.FONT_HERSHEY_SIMPLEX
col_names = ['Id', '', 'Name', '', 'Date', '', 'Time']
exists1 = [Link]("StudentDetails\[Link]")
if exists1:
44
df = pd.read_csv("StudentDetails\[Link]")
else:
mess._show(title='Details Missing', message='Students details are missing, please
check!')
[Link]()
[Link]()
[Link]()
while True:
ret, im = [Link]()
gray = [Link](im, cv2.COLOR_BGR2GRAY)
faces = [Link](gray, 1.2, 5)
for (x, y, w, h) in faces:
[Link](im, (x, y), (x + w, y + h), (225, 0, 0), 2)
serial, conf = [Link](gray[y:y + h, x:x + w])
if (conf < 50):
ts = [Link]()
date = [Link](ts).strftime('%d-%m-%Y')
timeStamp = [Link](ts).strftime('%H:%M:%S')
aa = [Link][df['SERIAL NO.'] == serial]['NAME'].values
ID = [Link][df['SERIAL NO.'] == serial]['ID'].values
ID = str(ID)
ID = ID[1:-1]
bb = str(aa)
bb = bb[2:-2]
attendance = [str(ID), '', bb, '', str(date), '', str(timeStamp)]
else:
Id = 'Unknown'
bb = str(Id)
[Link](im, str(bb), (x, y + h), font, 1, (255, 255, 255), 2)
45
[Link]('Taking Attendance', im)
if ([Link](1) == ord('q')):
break
ts = [Link]()
date = [Link](ts).strftime('%d-%m-%Y')
exists = [Link]("Attendance\Attendance_" + date + ".csv")
if exists:
with open("Attendance\Attendance_" + date + ".csv", 'a+') as csvFile1:
writer = [Link](csvFile1)
[Link](attendance)
[Link]()
else:
with open("Attendance\Attendance_" + date + ".csv", 'a+') as csvFile1:
writer = [Link](csvFile1)
[Link](col_names)
[Link](attendance)
[Link]()
with open("Attendance\Attendance_" + date + ".csv", 'r') as csvFile1:
reader1 = [Link](csvFile1)
for lines in reader1:
i=i+1
if (i > 1):
if (i % 2 != 0):
iidd = str(lines[0]) + ' '
[Link]('', 0, text=iidd, values=(str(lines[2]), str(lines[4]), str(lines[6])))
[Link]()
[Link]()
[Link]()
46
######################################## USED STUFFS
############################################
global key
key = ''
ts = [Link]()
date = [Link](ts).strftime('%d-%m-%Y')
day,month,year=[Link]("-")
mont={'01':'January',
'02':'February',
'03':'March',
'04':'April',
'05':'May',
'06':'June',
'07':'July',
'08':'August',
'09':'September',
'10':'October',
'11':'November',
'12':'December'
}
window = [Link]()
[Link]("1280x720")
[Link](True,False)
47
[Link]("Attendance System")
[Link](background='#262523')
48
head1 = [Link](frame1, text=" For Already Registered ",
fg="black",bg="#3ece48" ,font=('times', 17, ' bold ') )
[Link](x=0,y=0)
lbl3 = [Link](frame1,
text="Attendance",width=20 ,fg="black" ,bg="#00aeff" ,height=1 ,font=('times', 17, '
bold '))
[Link](x=100, y=115)
49
res=0
exists = [Link]("StudentDetails\[Link]")
if exists:
with open("StudentDetails\[Link]", 'r') as csvFile1:
reader1 = [Link](csvFile1)
for l in reader1:
res = res + 1
res = (res // 2) - 1
[Link]()
else:
res = 0
[Link](text='Total Registrations till now : '+str(res))
menubar = [Link](window,relief='ridge')
filemenu = [Link](menubar,tearoff=0)
filemenu.add_command(label='Change Password', command = change_pass)
filemenu.add_command(label='Contact Us', command = contact)
filemenu.add_command(label='Exit',command = [Link])
menubar.add_cascade(label='Help',font=('times', 29, ' bold '),menu=filemenu)
scroll=[Link](frame1,orient='vertical',command=[Link])
[Link](row=2,column=4,padx=(0,100),pady=(150,0),sticky='ns')
[Link](yscrollcommand=[Link])
51
trackImg = [Link](frame1, text="Take Attendance",
command=TrackImages ,fg="black" ,bg="yellow" ,width=35 ,height=1,
activebackground = "white" ,font=('times', 15, ' bold '))
[Link](x=30,y=50)
quitWindow = [Link](frame1, text="Quit",
command=[Link] ,fg="black" ,bg="red" ,width=35 ,height=1,
activebackground = "white" ,font=('times', 15, ' bold '))
[Link](x=30, y=450)
########################################################################
############################
52