0% found this document useful (0 votes)
58 views38 pages

Gogte Institute of Technology: Department of Computer Science & Engineering

This document describes a project report on an Automated Attendance System submitted by 4 students to fulfill the requirements for a Bachelor of Engineering degree. The system uses facial recognition to automate the attendance marking process, reducing the time spent on manual attendance recording. It detects faces, recognizes students by matching faces to a stored database, and marks their attendance accordingly. The report includes an introduction describing the purpose and scope of the project, the objectives and methodology. It also discusses prior systems, problem definition, initial design including GUI, functional blocks, use cases, and sequence diagrams. The source code and results are analyzed, with conclusions on future improvements.

Uploaded by

Rukmini Ghanti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views38 pages

Gogte Institute of Technology: Department of Computer Science & Engineering

This document describes a project report on an Automated Attendance System submitted by 4 students to fulfill the requirements for a Bachelor of Engineering degree. The system uses facial recognition to automate the attendance marking process, reducing the time spent on manual attendance recording. It detects faces, recognizes students by matching faces to a stored database, and marks their attendance accordingly. The report includes an introduction describing the purpose and scope of the project, the objectives and methodology. It also discusses prior systems, problem definition, initial design including GUI, functional blocks, use cases, and sequence diagrams. The source code and results are analyzed, with conclusions on future improvements.

Uploaded by

Rukmini Ghanti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

KARNATAKA LAW SOCIETY’S

GOGTE INSTITUTE OF TECHNOLOGY


UDYAMBAG, BELAGAVI-590008
(An Autonomous Institution under Visvesvaraya Technological University,
Belagavi) (APPROVED BY AICTE, NEW DELHI)

Department of Computer Science & Engineering

A Project Report on
“Automated Attendance System”
Submitted in the partial fulfilment for the award of the degree of

Bachelor of Engineering In
Computer Science & Engineering

Submitted by

K S Chitra : 2GI17CS047
Meghana Ghanti : 2GI17CS073
Tejashwini Gour : 2GI17CS151
Akshata Shirekar : 2GI17CS011

Guide
Prof. Arundhati Nelli
Assistant Professor, CSE
GIT, Belagavi

2020 – 2021
KARNATAKA LAW SOCIETY’S

GOGTE INSTITUTE OF TECHNOLOGY


UDYAMBAG, BELAGAVI-590008
(An Autonomous Institution under Visvesvaraya Technological University,
Belagavi) (APPROVED BY AICTE, NEW DELHI)

Department of Computer Science & Engineering

CERTIFICATE
Certified that the project entitled “Automated Attendance System” carried out by K S Chitra
(2GI17CS047), Meghana Ghanti (2GI17CS073), Tejashwini Gour (2GI17CS151), Akshata
Shirekar(2GI17CS011), students of KLS Gogte Institute of Technology, Belagavi, can be
considered as a bonafide work for partial fulfilment for the award of Bachelor of Engineering in
Computer science and engineering of the Visvesvaraya Technological University, Belagavi during
the year 2019- 2020. It is certified that all corrections/suggestions indicated have been incorporated
in the report. The project report has been approved as it satisfies the academic requirements
prescribed for the said Degree.

Guide HOD Principal


Date:

Final Viva-Voce
Name of the examiners Date of Viva -voce Signature

1.

2.

2
DECLARATION BY THE STUDENT

We, K S Chitra(2GI17CS047), Meghana Ghanti (2GI17CS073), Tejashwini Gour


(2GI17CS151), Akshata Shirekar(2GI17CS011), hereby declare that the project report entitled
“Automated Attendance System” submitted by us to KLS Gogte Institute of Technology,
Belagavi, in partial fulfilment of the Degree of Bachelor of Engineering in Computer Science
and Engineering is a record of the project carried out at Gogte institute of technology. This report
is for the academic purposes.

We further declare that the report has not been submitted and will not be submitted, either in part
or full, to any other institution and University for the award of any diploma or degree.

Name of the student USN Signature

K S Chitra 2GI17CS047

Meghana Ghanti 2GI17CS073

Tejashwini Gour 2GI17CS151

Akshata Shirekar 2GI17CS011

Place: Belgaum

Date:

3
ACKNOWLEDGEMENT

We take this opportunity to express our gratitude to all those people who have been
instrumental in making this project successful.

We feel honoured to place a warm salutation to K.L.S. GOGTE INSTITUTE OF


TECHNOLOGY, Belagavi, which gave the opportunity to study B.E. and strengthen our
knowledge base.

We would like to express sincere thanks to Dr.J.K.Kittur, Principal, G.I.T, Belagavi for his
warm support throughout the B.E. program.

We are extremely thankful to Dr. Vijay S.Rajpurohit, Professor & Head Dept of CSE, G.I.T,
Belagavi for his constant co-operation and support throughout this project.

We hereby express our thanks to Asst. Prof. Arundhati Nelli, Dept. of CSE, G.I.T, Belagavi
for being a guide for this project. She has provided us with incessant support and has been a
constant source of inspiration throughout the project.

We thank all our family members, friends and to all the Teaching, Non -Teaching and
Technical staff of Computer Science and Engineering Department, K.L.S. GOGTE
INSTITUTE OF TECHNOLOGY, Belagavi for their invaluable support and guidance.

K S Chitra

Meghana Ghanti

Tejashwini Gour

Akshata Shirekar

4
Abstract

Uniqueness or individuality of an individual is his face. In this project the face of an individual is
used for the purpose of attendance making automatically. Attendance of the students is very
important for every college, university and school. Conventional methodology for taking
attendance is by calling the name or roll number of the student and the attendance is recorded. Time
consumption for this purpose is an important point of concern. Assume that the duration for one
subject is around 60 minutes or 1 hour & to record attendance takes 5 to 10 minutes. For every tutor
this is consumption of time. To stay away from these losses, an automatic process is used in this
project which is based on image processing. In this project face detection and face reco gnition is
used. Face detection is used to locate the position of the face region and face recognition is used
for marking the understudy’s attendance. The database of all the students in the class is stored and
when the face of the individual student matches with one of the faces stored in the database thenthe
attendance is recorded. Facial recognition has always gone through a consistent research area due
to its non-modelling nature and its diverse applications. As a result, day -to-day activities are
increasingly being carried out electronically rather than in pencil and paper. Today, computer vision
is a comprehensive field that deals with a high level of programming by feeding the input
images/videos to automatically perform tasks such as detection, reco gnition and classification.
Even with deep learning techniques, they are better than the normal human visual system. In this
article, we developed a facial recognition system based on the Local Binary Pattern Histogram
(LBPH) method to treat the real-time recognition of the human face in the low and high-level
images. We aspire to maximize the variation that is relevant to facial expression and open edges so
to sort of encode edges in a very cheap way. These highly successful features are called the Local
Binary Pattern Histogram(LBPH).

5
Table of Contents

Content Page No.

i. Declaration 3

ii. Acknowledgement 4

iii. Abstract 5

iv. Table of contents 6

vi. List of Figures 8

1. Chapter 1 9

1.1 Introduction 9

1.1.1 Purpose 9

1.1.2 Product scope 9

1.1.3 1.1.3. Product Perspective 9

1.2 Objectives 10

1.3 Methodology 10

2 Chapter 2 15

2.1 Survey 15

2.1.1 Data collected 15

2.1.2 Processing of data 15

6
2.2 Experimental work Conducted 16

2.3 Finalization of Contents of the project 16

3 Chapter 3 18

3.1 Prior art search 18

4 Chapter 4 22

4.1 Problem definition 22

4.2 Initial design 22

4.3 Source code 26

5 Chapter 5 36

5.1 Results and discussion 36

6 Chapter 6 37

6.1 Conclusion and future scope 37

References 38

7
List of Figures:

1. GUI Design
2. Functional block
3. Use case diagram
4. Sequence diagram
5. Software architecture diagram

8
AUTOMATED ATTENDANCE SYSTEM

CHAPTER 1:

1.1 Introduction

1.1.1 Purpose

The purpose of this software is to describe the requirements for developing an smart attendance named
“Automated Attendance System”. An attendance of a student is proof for a teacher that student has
attended the class. By developing this software it would help many colleges, schools, universities to
take and mark the attendance of all the students through an automated attendance system which will
capture several pictures of a student and stores it into a database with their name, roll number, time,
subject name, course. Once the student is registered into the database, there is no need for him/her to
register again. It is a time saving process for every teacher as the class is conducted for 60min more
or less, attendance is taken through the camera itself and there won’t be any proxy from student side.

1.1.2 Product Scope


This project is such an application which will be holding the overall information of the student
with name, course, subject name, time etc. This can be installed in any classroom to record the
attendance given the classroom has a camera installed .This camera is used to capture the student
images in real time and processed in the backend to detect the face of the student. Before using this
in a real time environment , all the students must be registered to the system using their id and name.

1.1.3 Product Perspective

This system is intended to replace the manual model of attendance record keeping by means of roll
call and paper records. The roll call and paper records are replaced with a single interaction between
the professor and the system. Teachers will be able to view details regarding attendance of individual
students on their PC and quickly maintain attendance records. The system will be developed in such
a way to provide easy addition of enhanced features, which may be desired in subsequent versions

KLS GOGTE INSTITUTE OF TECHNOLOGY 9


AUTOMATED ATTENDANCE SYSTEM

1.2 Objectives
• Our project “Automated attendance system” is a knowledgeable tool which helps teachers to
take attendance of every student at a time.
• It helps teachers from proxy attendance of students.
• No need to enter details of students every time, once details are registered it will be saved in
the database.
• The objective of this project is to make the attendance marking and management system
fully automatic, simple, easy.
• Provides necessary information in a single click.

1.3 Methodology
Details of the overall methodology followed is explained by a software arch itecture diagram.Software
has registration part which is developed using tkinter GUI and in the backend it uses
CascadeClassifier to detect faces and also uses LBPH(Local Binary Patterns Histograms) algorithm
to recognise the face of the student.

A.Face detection
When the student get registered to the application their images are captured and saved in a folder
which is used later for training.However,only face of the face of the individual is required for training
the face recognition model.So,before saving it in a folder we detect the faces from the images captured
and only images of the face are saved for training.One of the efficient face detection algorithm used
here is OpenCv CascadeClassifier.

Haar CascadeClassifier:
Face detection using Haar cascades is a machine learning based approach where a cascade function is
trained with a set of input data. OpenCV already contains many pre-trained classifiers for face, eyes,
smiles, etc. Object Detection using Haar feature-based cascade classifiers is an effective object
detection method proposed by Paul Viola and Michael Jones in their paper, "Rapid Object Detection

KLS GOGTE INSTITUTE OF TECHNOLOGY 10


AUTOMATED ATTENDANCE SYSTEM

using a Boosted Cascade of Simple Features" in 2001. It is an approach where a cascade function is
trained from a lot of positive and negative images. It is then used to detect objects in other images.
Initially, the algorithm needs a lot of positive images (images of faces) and negative images (images
without faces) to train the classifier. Then we need to extract features from it. For this, Haar features
shown in the below image are used. They are just like convolutional kernel. Each feature is a single
value obtained by subtracting the sum of pixels under the white rectangle from the sum of pixels under
the black rectangle.

image
Now, all possible sizes and locations of each kernel are used to calculate lots of features. For each
feature calculation, we need to find the sum of the pixels under white and black rectangles. To solve
this, they introduced the integral image. However large the image, it reduces the calculations for a
given pixel to an operation involving just four pixels.

OpenCV provides a training method for pretrained models.In our work we have used pretrained
models which are trained using images with faces as positive class and Images without face as
negative class for classifier. The accuracy of this classifier is almost 100% reliable and it is observed
that it is significantly fast while performing face detection.

KLS GOGTE INSTITUTE OF TECHNOLOGY 11


AUTOMATED ATTENDANCE SYSTEM

B. Face Recognition
Local Binary Patterns Histograms (LBPH) Face Recognizer
We observed that Eigenfaces and Fisher faces are both affected by light and in real life we can't
guarantee perfect light conditions. LBPH face recognizer is an improvement to overcome this
drawback.Idea used here is to look at the image as a whole instead of finding the local features of an
image. LBPH algorithm try to find the local structure of an image and it does that by comparing each
pixel with its neighboring pixels.

Fig: Finding a decimal Value


The algorithm is named as Local Binary because it gets the list of local binary patterns. after it gets
the list of local binary patterns it converts each binary pattern into a decimal number (as shown in
above image) and then it makes a histogram of all of those values. A sample histogram looks like this.

Fig: Final concatenated Histogram

KLS GOGTE INSTITUTE OF TECHNOLOGY 12


AUTOMATED ATTENDANCE SYSTEM

So in the end we will have one histogram for each face image in the training data set. That means if
there were 100 images in the training data set then LBPH will extract 100 histograms after training
and store them for later recognition. The algorithm also keeps track of which histogram belongs to
which person.Later during recognition, It will feed a new image to the recognizer for recognition. It
will generate a histogram for that new image, compare that histogram with the histograms it already
has, find the best match histogram and return the person label associated with that best match
histogram.

Operations in steps:
• Convert facial image to grayscale.
• Select a window of 3×3 pixels. It will be a 3×3 matrix containing the intensity of each pixel
(0~255).
• Take the central value of the matrix and use it to threshold the neighbouring pixels.
• For each neighbour of the central value (threshold), we set a new binary value. set 1 for values
equal or higher than the threshold and 0 for values lower than the threshold.
• The matrix will contain only binary values (ignoring the central value). We need to
concatenate each binary value from each position from the matrix line by line into a new binary
value (e.g. 10001101).
• Then, we convert this binary value to a decimal value and set it to the central value of the
matrix, which is actually a pixel from the original image.
• At the end of this procedure (LBP procedure), we have a new image which better represents
the characteristics of the original image.
Extract histogram of the LBP patterns by dividing the image into a Grid.
As we have an image in grayscale, each histogram (from each grid) will contain only 256 positions
(0~255) representing the occurrences of each pixel intensity.Then, we need to concatenate each
histogram to create a new and bigger histogram. Supposing we have 8×8 grids, we will have
8x8x256=16.384 positions in the final histogram. The final histogram represents the characteristics
of the original image.Face images are compared by converting both into LBPH vectors and then

KLS GOGTE INSTITUTE OF TECHNOLOGY 13


AUTOMATED ATTENDANCE SYSTEM

calculating the distance between two histograms, for example: Euclidean distance, chi-square,
absolute value, etc.

CONCLUSIONS
• LBPH is one of the easiest face recognition algorithms.
• It can represent local features in the images.
• It is possible to get great results mainly in a controlled environment.
• It is robust against monotonic gray scale transformations.

KLS GOGTE INSTITUTE OF TECHNOLOGY 14


AUTOMATED ATTENDANCE SYSTEM

CHAPTER 2
2.1 Survey
A) Data Collected
2.1.1 Data Collection
Data collection step is preceded with Image Acquisition and then Dataset creation.

2.1.1.1 Image Acquisition


Data needs to be collected using a good quality camera which is placed in the classroom. However
we collected data for model building and training using a webcam available in the laptop. Image data
should be collected regularly during the recording of attendance.
2.1.1.2 Dataset Creation
Students' dataset is created before the face recognition process. Dataset was created only to build and
train the model . We have created a dataset of 4 students which involves their name, id and images of
students in different poses and variations taken using a webcam . For better accuracy minimum 100
images of each student should be captured. This process of collecting student information along with
their details takes place as part of the registration process.

B) Processing of Data
Images of the students that are collected are first preprocessed before training it with a face recognition
algorithm.As explained in [5],we concluded that the color of the image does not add noticeable
difference in accuracy of the face recognition algorithms.So collected Images are converted into
grayscale format which involves converting RGB images captured by camera into grayscale images.
Since we need only the face of the student to build a face recognition model ,images are passed
through face detection algorithms which detect a face by finding the bounding box of the face. These
bounding boxes are used to crop the image to only face. These face images are stored in the students
directory with students name as folder name and id.count as image name.

KLS GOGTE INSTITUTE OF TECHNOLOGY 15


AUTOMATED ATTENDANCE SYSTEM

Other information collected from students such as name and Id are stored in a separate csv file which
will be used later to record the attendance. We also collect the timetable data which will be used to
save the recorded attendance in subject wise folders which will really help to track the attendance
easily.

C) Experimental work Conducted


This project as a whole basically involved two things. First one is building a User interface which
helps users to interact with applications in the easiest way. Second one is building a model which can
predict the student based on his/her face. UI is built as a simple python tkinter application and the
model is built using LBPH face recogniser. We have also experimented the model training with other
algorithms like EigenFaces Face Recognizer and Fisher face recogniser which did not yield good
accuracy like LBPH.

Due to circumstance and limited access to classroom/college , the model was not trained on real time
classroom scenarios. Instead different models are studied and experimented with publicly available
face data . Famous celebrity face Images data available on kaggle is used to understand the use of
different algorithms in different situations. LBPH being the local feature extract face recognizer
performed significantly well on this dataset as compared to other algorithms. LBPH is later trained
using images captured by webcam on four different students to imitate the real time scenarios.
Advantages:
A] Automated time tracking system
B] Cost-effective
D] Increased security
D] Time saving
E] Easy to manage

D) Finalization of Content of the project


This application is built to provide end to end management of attendance taking procedures . The
whole project is built in such a way that college can handle part of registering students with the click

KLS GOGTE INSTITUTE OF TECHNOLOGY 16


AUTOMATED ATTENDANCE SYSTEM

of few buttons and access the recorded attendance using simple csv files which can be replaced by
Database management system in future for secure and reliable performance.

The prototype of this project is built and hosted in the laptop itself. Users(College) have the option to
register the students, train the model with newly registered students and track the presence and
absence of the student.Before using this application,all the students must be registered with
application by providing basic details and few poses in front of camera from which training data set
will be created. College can also update the timetable using a csv file. Our application dynamically
reads the contents of the time table and using the system's current time finds the subject on that
particular day and time. All the recorded attendance are arranged in different subject wise folder for
easy tracking of attendees.

KLS GOGTE INSTITUTE OF TECHNOLOGY 17


AUTOMATED ATTENDANCE SYSTEM

CHAPTER 3
3.1 Prior Art search
The proposed method for automated attendance recording here is using Face detection/recognition
technique. However there are many other methods used for recording attendance automatically such
as RFID (Radio Frequency Identification) card system, fingerprint system , iris recognition system ,
Voice recognition system etc.

A.ROC: L-68583/2017 RFID Based Attendance System

Abstract
Radio Frequency Identification (RFID) based attendance system is one of the solutions to address this
problem. This system can be used to take attendance for student in school, college, and university. It
also can be used to take attendance for workers in working places. Its ability to uniquely identify each
person based on their RFID tag type of ID card make the process of taking the attendance easier, faster
and secure as compared to conventional method. Students or workers only need to place their ID card
on the reader and their attendance will be taken immediately. With real time clock capability of the
system, attendance taken will be more accurate since the time for the attendance taken will be
recorded. The system can be connected to the computer through RS232 or Universal Serial Bus (USB)
port and store the attendance taken inside database. An alternative way of v iewing the recorded
attendance is by using HyperTerminal software. A prototype of the system has been successfully
fabricated.

Background Description
RFID based attendance system has an RFID reader, RFID Tag, LCD display & a microcontroller unit
that allows the wireless communications to establish the identity of students, faculty, or any other
staff. RFID attendance system provides wireless identification of stakeholders when they fall in the
radiofrequency range of the RFID attendance reader. To mark the attendance automatically, the
students or staff need to carry the RFID tag that contains unique information about them such as
class/section/name/ID number. The receiver/reader of the RFID attendance system automatically

KLS GOGTE INSTITUTE OF TECHNOLOGY 18


AUTOMATED ATTENDANCE SYSTEM

registers the attendance & saves the attendance data in the system. The administrator can anytime
extract the data to get a summary of student attendance history & keep a tab on them as well as faculty
attendance for salary & payroll management.

Claims:
RFID methodology is quick and efficient , However This system may give rise to the problem
of fraudulent approaches. An Unauthorized students may make use of RFID card and enter
into the organization. Also the user tends to help their friends to check in as long as they have their
friend’s ID card which makes proxy easier.Proposed methodology uses the face recognition
techniques which uses face of the student to identify him which helps to restrict unauthorized persons
and also avoids proxy. Students no need to worry about keep an Id card.

B.Electronic ISBN:978-1-4799-6322-5 Implementation of face recognition algorithm for


biometrics based time attendance system

Abstract:
Face Recognition begins with extracting the coordinates of features such as width of mouth, width of
eyes, pupil, and comparing the result with the measurements stored in the database and returning the
closest record (facial metrics). Nowadays, there are a lot of face recognition techniques and algorithms
found and developed around the world. Facial recognition becomes an interesting research topic. It is
proven by numerous published papers related to facial recognition including facial fe ature extraction,
facial algorithm improvements, and facial recognition implementations. Main purposes of this
research are to get the best facial recognition algorithm (Eigenface and Fisherface) provided by the
OpenCV 2.4.8 by comparing the ROC (Receiver Operating Characteristics) curve and implement it
in the attendance system as the main case study. Based on the experiments, the ROC curve proves
that using the current training set, Eigenface achieves better result than Fisherface. Eigenface
implemented inside the Attendance System returns between 70% to 90% similarity for genuine face
images.

KLS GOGTE INSTITUTE OF TECHNOLOGY 19


AUTOMATED ATTENDANCE SYSTEM

Methodology used:

1. Eigenfaces Face Recognizer


This algorithm considers the fact that not all parts of a face are equally important and equally useful.
When you look at someone you recognize him/her by his distinct features like eyes, nose, cheeks,
forehead and how they vary with respect to each other. So you are actually focusing on the areas of
maximum change (mathematically speaking, this change is variance) of the face. For example, from
eyes to nose there is a significant change and same is the case from nose to mouth. When you look at
multiple faces you compare them by looking at these parts of the faces because these parts are the
most useful and important components of a face. Important because they catch the maximum change
among faces, change the helps you differentiate one face from the other. This is exactly how
EigenFaces face recognizer works.

EigenFaces face recognizer looks at all the training images of all the persons as a whole and try to
extract the components which are important and useful (the components that catch the maximum
variance/change) and discards the rest of the components. This way it not only extracts the important
components from the training data but also saves memory by discarding the less important
components. These important components it extracts are called principal components.

2. Fisher Faces Face Recognizer


This algorithm is an improved version of EigenFaces face recognizer. Eigenfaces face recognizer
looks at all the training faces of all the persons at once and finds principal components from all of
them combined. By capturing principal components from all the of them combined you are not
focusing on the features that discriminate one person from the other but the features that represent all
the persons in the training data as a whole.This approach has drawbacks, for example, images with
sharp changes (like light changes which is not a useful feature at all) may dominate the rest of the
images and you may end up with features that are from external source like light and are not useful
for discrimination at all. In the end, your principal components will represent light changes and not
the actual face features.

KLS GOGTE INSTITUTE OF TECHNOLOGY 20


AUTOMATED ATTENDANCE SYSTEM

Fisher faces algorithm, instead of extracting useful features that represent all the faces of all the
persons, it extracts useful features that discriminate one person from the others. This way features of
one person do not dominate over the others and you have the features that discriminate one person
from the others.

Claims:
The algorithm proposed here uses Eigenfaces Face Recognizer
And fisher faces recognizer which is not very efficient compared to LBPH algorithm.In Eigenfaces
faces recognizer The feature extractor must be retrained if large number of new faces are added to the
system.It is not accurate enough by itself and needs boosting methods for improvement.Even fisher
method is sensitive to different lighting condition,hence less accurate.Also the software used in our
work supports more features like arrangement of attendance subject wise and registering new students
without hassle.

KLS GOGTE INSTITUTE OF TECHNOLOGY 21


AUTOMATED ATTENDANCE SYSTEM

CHAPTER 4
4.1 Problem Definition
To design and develop a software system that automates the traditional attendance system which
records the presence of the student using face recognition techniques.

4.2 Initial Design


GUI Design

KLS GOGTE INSTITUTE OF TECHNOLOGY 22


AUTOMATED ATTENDANCE SYSTEM

Functional block

KLS GOGTE INSTITUTE OF TECHNOLOGY 23


AUTOMATED ATTENDANCE SYSTEM

Sequence Diagram:

KLS GOGTE INSTITUTE OF TECHNOLOGY 24


AUTOMATED ATTENDANCE SYSTEM

Software Architecture Diagram:

KLS GOGTE INSTITUTE OF TECHNOLOGY 25


AUTOMATED ATTENDANCE SYSTEM

Source code
A. Main file
"""
Created on Thu Feb 18 18:01:17 2021
@author: kschitra
"""
import tkinter as tk
from tkinter import Message ,Text
import cv2,os
import shutil
import csv
import numpy as np
from PIL import Image, ImageTk
import pandas as pd
import datetime
import time
import tkinter.ttk as ttk
import tkinter.font as font
from functions import Image_Labels,is_number
from Timetable import subject

mainscreen = tk.Toplevel()
mainscreen.title("Face_Recogniser")
mainscreen.configure(background='#1F2833')
mainscreen.grid_rowconfigure(0, weight=1)
mainscreen.grid_columnconfigure(0, weight=1)
path = "back1.jpg"
img = ImageTk.PhotoImage(Image.open(path))
pnl = tk.Label(mainscreen, image = img)
pnl.pack(side = "left", fill = "y", expand = "no")

KLS GOGTE INSTITUTE OF TECHNOLOGY 26


AUTOMATED ATTENDANCE SYSTEM

lb0 = tk.Label(mainscreen, text="GIT Attendance-Management-System",width=50 ,height=3


,fg="white" ,bg="#45A29E" ,font=('times', 25, ' bold ') )
lb0.place(x=200, y=20)

message = tk.Label(mainscreen, text="Dash Board" ,bg="black" ,fg="white" ,width=20


,height=5,font=('times', 22, 'bold'))
#GIT Attendance-Management-System
message.place(x=900, y=200)

lbl = tk.Label(mainscreen, text="Enter ID",width=20 ,height=2 ,fg="white" ,bg="#45A29E"


,font=('times', 15, ' bold ') )
lbl.place(x=90, y=200)

txt = tk.Entry(mainscreen,width=20 ,bg="#66FCF1" ,fg="black",font=('times', 15, ' bold '))


txt.place(x=390, y=200,width=200,height=60)

lbl2 = tk.Label(mainscreen, text="Enter Name",width=20 ,fg="white" ,bg="#45A29E" ,height=2


,font=('times', 15, ' bold '))
lbl2.place(x=90, y=300)

txt2 = tk.Entry(mainscreen,width=20 ,bg="#66FCF1" ,fg="black",font=('times', 15, ' bold ') )


txt2.place(x=390, y=300,width=200,height=60)

def clear_button1():
txt.delete(0, 'end')
result = "Id cleared"
message.configure(text= result)

KLS GOGTE INSTITUTE OF TECHNOLOGY 27


AUTOMATED ATTENDANCE SYSTEM

def clear_button2():
txt2.delete(0, 'end')
result = "Name cleared"
message.configure(text= result)

def Prepare():
Student_ID=(txt.get())
name=(txt2.get())
if(is_number(Student_ID) and name.replace(' ','').isalpha()):
df=pd.read_csv("Registered_student.csv")
#print(len(df[df['Student_ID']==int(Student_ID)]))
if len(df[df['Student_ID']==int(Student_ID)]) and len(df[df['Name']==name]):
res="Student ID and \nName already registered"
message.configure(text= res)
elif len(df[df['Student_ID']==int(Student_ID)]):
res="Student ID is \nalready registered"
message.configure(text= res)
else:
cam = cv2.VideoCapture(0)
harcascadePath = "haarcascade_frontalface_default.xml"
detector=cv2.CascadeClassifier(harcascadePath)
sampleNum=0
while(True):
ret, img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = detector.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)

KLS GOGTE INSTITUTE OF TECHNOLOGY 28


AUTOMATED ATTENDANCE SYSTEM

sampleNum=sampleNum+1

cv2.imwrite("Image_train\ "+name +"."+Student_ID +'.'+ str(sampleNum) + ".jpg",


gray[y:y+h,x:x+w])

cv2.imshow('frame',img)

if cv2.waitKey(100) & 0xFF == ord('q'):


break

elif sampleNum>60:
break
cam.release()
cv2.destroyAllWindows()
res = "Images Saved for \nID : "+ Student_ID +"\nName : "+ name
row = [Student_ID , name]
with open('Registered_student.csv','a+') as csvFile:
writer = csv.writer(csvFile)
writer.writerow(row)
csvFile.close()

message.configure(text= res)
else:
if(is_number(Student_ID)):
res = "Enter Alphabetical Name"
message.configure(text= res)
if(name.isalpha()):
res = "Enter Numeric ID"

KLS GOGTE INSTITUTE OF TECHNOLOGY 29


AUTOMATED ATTENDANCE SYSTEM

message.configure(text= res)

def Train():
recognizer = cv2.face_LBPHFaceRecognizer.create()#recognizer =
cv2.face.LBPHFaceRecognizer_create()#$cv2.createLBPHFaceRecognizer()
harcascadePath = "haarcascade_frontalface_default.xml"
detector =cv2.CascadeClassifier(harcascadePath)

faces,s_Id = Image_Labels("Image_train")
recognizer.train(faces, np.array(s_Id))
recognizer.save("Train.yml")
result = "Image Trained"#+",".join(str(f) for f in Id)
message.configure(text= result)

def Track():
recognizer = cv2.face.LBPHFaceRecognizer_create()#cv2.createLBPHFaceRecognizer()
recognizer.read("Train.yml")
harcascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(harcascadePath);
df=pd.read_csv("Registered_student.csv")
cam = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_SIMPLEX
col_names = ['Id','Name','Date','Time']
attendance = pd.DataFrame(columns = col_names)
while True:
ret, im =cam.read()
gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)

KLS GOGTE INSTITUTE OF TECHNOLOGY 30


AUTOMATED ATTENDANCE SYSTEM

faces=faceCascade.detectMultiScale(gray, 1.2,5)
for(x,y,w,h) in faces:
cv2.rectangle(im,(x,y),(x+w,y+h),(225,0,0),2)
Id, conf = recognizer.predict(gray[y:y+h,x:x+w])
if(conf < 50):
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
aa=df.loc[df['Student_ID'] == Id]['Name'].values
print(aa)
print(type(aa))
tt=str(Id)+"-"+aa

attendance.loc[len(attendance)] = [Id,aa,date,timeStamp]

aa=df.loc[df['Student_ID'] == Id]['Name'].values
tt=str(Id)+"-"+aa
attendance.loc[len(attendance)] = [Id,aa,date,timeStamp]

else:
Id='Unknown'
tt=str(Id)
#message.configure(text=str("Unknown") )
if(conf > 75):
noOfFile=len(os.listdir("Unknown"))+1
cv2.imwrite("Unknown\Image"+str(noOfFile) + ".jpg", im[y:y+h,x:x+w])
cv2.putText(im,str(tt),(x,y+h), font, 1,(255,255,255),2)
attendance=attendance.drop_duplicates(subset=['Id'],keep='first')

KLS GOGTE INSTITUTE OF TECHNOLOGY 31


AUTOMATED ATTENDANCE SYSTEM

cv2.imshow('im',im)
if (cv2.waitKey(1)==ord('q')):
break
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
Hour,Minute,Second=timeStamp.split(":")
sub=subject()
if sub=="NULL" or sub=="BREAK":
fileName="Record\Other\Attendance_"+date+"_"+Hour+"-"+Minute+"-"+Second+".csv"
attendance.to_csv(fileName,index=False)
else:
if not os.path.exists('Record\{}'.format(sub)):
os.makedirs('Record\{}'.format(sub))
fileName="Record\{}\Attendance_{}_{}-{}-{}.csv".format(sub,date,Hour,Minute,Second)
attendance.to_csv(fileName,index=False)

cam.release()
cv2.destroyAllWindows()

clearButton = tk.Button(mainscreen, text="Clear", command=clear_button1 ,fg="white"


,bg="#1F2833" ,width=18 ,height=2 ,activebackground = "Red" ,font=('times', 15, ' bold '))
clearButton.place(x=640, y=200)
clearButton2 = tk.Button(mainscreen, text="Clear", command=clear_button2 ,fg="white"
,bg="#1F2833" ,width=18 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
clearButton2.place(x=640, y=300)
takeImg = tk.Button(mainscreen, text="Take Images", command=Prepare ,fg="white" ,bg="black"
,width=20 ,height=3, activebackground = "Red" ,font=('times', 15, ' bold '))

KLS GOGTE INSTITUTE OF TECHNOLOGY 32


AUTOMATED ATTENDANCE SYSTEM

takeImg.place(x=150, y=500)
trainImg = tk.Button(mainscreen, text="Train Images", command=Train ,fg="white" ,bg="black"
,width=20 ,height=3, activebackground = "Red" ,font=('times', 15, ' bold '))
trainImg.place(x=450, y=500)
trackImg = tk.Button(mainscreen, text="Track Images", command=Track ,fg="white" ,bg="black"
,width=20 ,height=3, activebackground = "Red" ,font=('times', 15, ' bold '))
trackImg.place(x=750, y=500)

quitmainscreen = tk.Button(mainscreen, text="Quit", command=mainscreen.destroy ,fg="white"


,bg="black" ,width=20 ,height=3, activebackground = "Red" ,font=('times', 15, ' bold '))
quitmainscreen.place(x=1050, y=500)

mainscreen.mainloop()

B. Helper Functions
"""
Created on Fri April 08 18:01:17 2021

@author: kschitra
"""
import os
import numpy as np
from PIL import Image
def Image_Labels(path):
path="Image_train"
imagePaths=[os.path.join(path,f) for f in os.listdir(path)]
faces=[]
Ids=[]

KLS GOGTE INSTITUTE OF TECHNOLOGY 33


AUTOMATED ATTENDANCE SYSTEM

for imagePath in imagePaths:

pilImage=Image.open(imagePath).convert('L')

imageNp=np.array(pilImage,'uint8')

Id=int(os.path.split(imagePath)[-1].split(".")[1])

faces.append(imageNp)
Ids.append(Id)
return faces,Ids

def is_number(s):
try:
float(s)
return True
except ValueError:
pass

try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass

KLS GOGTE INSTITUTE OF TECHNOLOGY 34


AUTOMATED ATTENDANCE SYSTEM

return False

C. Time Table Functions


"""
Created on Tue May 20 19:16:48 2021
@author: kschitra

"""
import pandas as pd
import datetime
from datetime import datetime as date
df=pd.read_csv('Timetable.csv')

def subject():
day=date.today().strftime("%A")
time = date.now().strftime('%Y-%m-%d %H:%M:%S')[11:-3]
hr=int(time[0:2])
mi=int(time[3:5])
current_time=datetime.time(hr,mi)
#current_time=datetime.time(10,46)
ti=list(df['Timings'].values)
for i in ti:
a=datetime.time(int(i[0:2]),int(i[3:5]))
b=datetime.time(int(i[6:8]),int(i[9:12]))
if current_time >=a and current_time<b:
subject=df[day].loc[(ti.index(i))]
return subject
return "NULL"

KLS GOGTE INSTITUTE OF TECHNOLOGY 35


AUTOMATED ATTENDANCE SYSTEM

CHAPTER 5
5.1 Results and Discussion
Automated attendance system allows to record attendance of the students.In this proposed approach,
face recognition student attendance system with user friendly interface is designed by using Tkinter
GUI(Graphic User Interface). A few buttons are designed in the interface, each provides a specific
function, for example, the take images button is to initialize the camera and allows enrollment or
registrations of students and the train images button is to train the latest images that have been
registered in the database. Lastly, the track images button is to browse facial images from the selected
database and update the attendance record respectively.

Face recognition is the identification of an individual by comparing his/her real-time captured image
with stored images in the database of that person. Thus, the training set has to be chosen based on the
latest appearance of an individual Attendance system proved to recognize images in different angles
and light conditions. The faces which are not in our train ing dataset are marked as unknown.The
attendance of recognized images of students is marked in real time.

KLS GOGTE INSTITUTE OF TECHNOLOGY 36


AUTOMATED ATTENDANCE SYSTEM

CHAPTER 6
6.1 Conclusion and Future Scope
This system has been proposed for maintaining the attendance record. The main motive behind
developing this system is to eliminate all the drawbacks which were associated with the manual
attendance system. The drawbacks ranging from wastage of time and paper, till the proxy issu
There are many other techniques to implement Automated attendance system. RFID card system is
implemented due to its simplicity. However, the user tends to help their friends to check in as long as
they have their friend’s ID card. The fingerprint system is indeed effective but not efficient because
it takes time for the verification process so the user has to line up and perform the verification one by
one. However for face recognition, the human face is always exposed and contains less information
compared to iris. Iris recognition system which contains more detail might invade the privacy of the
user. So face detection methods hold good in most of the scenarios.Automated attendance
management system is designed to solve the issues of existing manual systems.. The system performs
satisfactorily in different poses and variations since it uses a comparatively simple recognizer like
LBPH.The model accuracy can be further increased in the future using advanced algorithms like
Deep neural network. Current system needs improvement because this system sometimes fails to
recognize students from far distances. Deploying Deep learning architecture might help to mitigate
these limitations.

KLS GOGTE INSTITUTE OF TECHNOLOGY 37


AUTOMATED ATTENDANCE SYSTEM

References

[1] Automatic Face Recognition Attendance System using Python and OpenCv by Dr. Asif Ali,
Radhika mandhanya, Shraddha Birla, Vipul Jain.
[2] Smart Attendance Management System Using face recognition by Kaneez.L.B, Laraib Mughal,
Faheem.Y.K, Sheeraz.A.M.
[3] Software Requirements specification for Attendance Management System by Varun Sharma and
Gopesh Raval.
[4] The Proposed Implementation of RFID based attendance system by Rizwan Qureshi.
Bluetooth Smart based Attendance Management System by Riya Lodha, Suruchi Gupta, Harshil Jain,
Harish Narula.
[5] Kar, Nirmalya, et al. "Study of implementing automated attendance system using face
recognition technique." International Journal of computer and communication engineering 1.2 [2012]:
100
[6] Selvi, K. Senthamil, P. Chitrakala, and A. Antony Jenitha. "Face recognition based attendance
marking system."
[7] Ashwini, C.,et al. "An Efficient Attendance System Using Local Binary Pattern and Local
Directional Pattern." Journal of Network Communications and Emerging Technologies (JNCET)
www. jncet. org 8.4 [2018].
[8] Dr C.Sunil Kumar1 , C.N Ravi2 and J.Dinesh3. Human Face Recognition and Detection System
with Genetic and Ant Colony Optimization Algorithm IOSR Journal of Computer Engineering
(IOSRJCE) e-ISSN: 2278-0661,p-ISSN: 2278-8727, Volume 16, Issue 4, Ver. VII, Jul – Aug. 2014
Role of Color in FaceRecognition by Andrew Yip and Pawan Sinha.

KLS GOGTE INSTITUTE OF TECHNOLOGY 38

You might also like