0% found this document useful (0 votes)
192 views

Real Time Face Detection Report

This document describes a project that aims to develop a real-time face detection attendance monitoring system. It begins with an introduction that outlines the problems with traditional attendance methods and significance of automating the process. The scope involves using OpenCV for real-time face detection. It then discusses the literature survey, existing fingerprint-based system, proposed face recognition system, hardware and software requirements including modules like OpenCV, face recognition and databases. It elaborates on the system design with modules like face detection, recognition, attendance tracking and user interface. It concludes with discussing results, future scope and references.

Uploaded by

blessingj19it018
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
192 views

Real Time Face Detection Report

This document describes a project that aims to develop a real-time face detection attendance monitoring system. It begins with an introduction that outlines the problems with traditional attendance methods and significance of automating the process. The scope involves using OpenCV for real-time face detection. It then discusses the literature survey, existing fingerprint-based system, proposed face recognition system, hardware and software requirements including modules like OpenCV, face recognition and databases. It elaborates on the system design with modules like face detection, recognition, attendance tracking and user interface. It concludes with discussing results, future scope and references.

Uploaded by

blessingj19it018
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

REAL TIME FACE DETECTION ATTENDANCE

MONITORING
A PROJECT REPORT
Submitted by,
ABIJITHNIKASH.M (310819205004)
HARESH.M (310819205035)
NANDHA KUMAR.V (310819205048)

In the partial fulfilment for the award of the degree

of

BACHELOR OF TECHNOLOGY

in

INFORMATION TECHNOLOGY

JEPPIAAR ENGINEERING COLLEGE

ANNA UNIVERSITY
CHENNAI 600 025
MAY 2023

1
JEPPIAAR ENGINEERING COLLEGE
DEPARTMENT OF INFORMATION TECHNOLOGY
JEPPIAAR NAGAR, RAJIV GANDHI ROAD, CHENNAI-119

BONAFIDE CERTIFICATE

This is to certify that this Project Report “REAL TIME FACE DETECTION
ATTENDANCE MONITORING” is the Bonafide work of
“ABIJITHNIKASH.M & HARESH.M & NANDHA KUMAR.V” who carried
out the project under my supervision.

SUPERVISOR HEAD OF DEPARTMENT


Dr. L.K.Shoba, M.Tech., Ph.D., Dr. S.Venkatesh, M.E., Ph.D.,
Assistant Professor, Assistant Professor,
Department of IT, Department of IT,
Jeppiaar Engineering College, Jeppiaar Engineering College,
Chennai 600 119. Chennai 600 119.

Submitted for the project viva voce examination held on ___________

INTERNAL EXAMINER EXTERNAL EXAMINER

2
ACKNOWLEDGEMENT

We are very much indebted to (Late) Hon’ble Colonel Dr. JEPPIAAR, M.A.,
B.L., Ph.D., Our Chairman and Managing Director Dr. REGEENA.J. MURALI,
B. Tech., M.B.A., Ph.D., the Principal Dr. J. FRANCIS XAVIER, M.Tech.,
Ph.D., and the Dean Academics Dr. SHALEESHA A. STANLEY M.Sc.,
M.Phil., Ph.D., to carry out the project here.

We would like to express our deep sense of gratitude to Dr. S. Venkatesh, M.E.,
Ph.D., Head of the Department and also to our guide Dr. L.K. Shoba, M.Tech.,
Ph.D., for giving valuable suggestions for making this project a grand success.

We take this opportunity to express our sincere gratitude to our Project coordinator
Mrs. T. Anuja, M.Tech., for giving us the opportunity to do this project under
their esteemed guidance.

We also thank the teaching and non-teaching staff members of the department of
Information Technology for their constant support.

i
ABSTRACT

• The management of the attendance can be a great burden on the


teachers if it is done by hand. To resolve this problem, smart and
auto attendance management system is being utilized. By
utilizing this framework, the problem of proxies and students
being marked present even though they are not physically
present can easily be solved. The frames are extracted from video
using OpenCV. The main implementation steps used in this type
of system are face detection and recognizing the detected face,
for which dlib is used. After these, the connection of recognized
faces ought to be conceivable by comparing with the database
containing student's faces. This model will be a successful
technique to manage the attendance of students.

• Live Webcam based Face Attendance System Project through


python programming.

• Smart Attendance Management System is an application


developed for daily student attendance in colleges or schools.

• This project attempts to record attendance through face


detection.

ii
TABLE OF CONTENT

CHAPTER TITLE PAGE NO


1 1.1 INTRODUCTION 1
1.2 PROBLEM STATEMENT 1
1.3 SIGNIFICANCE 2
1.4 SCOPE OF THE PROJECT
1.4.1 Real-Time Face Detection Using OpenCV 2

2 2.1 LITRATURE SURVEY 4

3 SYSTEM ANALYSIS
3.1 INTRODUCTION 7
3.2 EXISTING SYSTEM
3.2.1 Fingerprint Based Recognition System 7
3.3 PROPOSED SYSTEM 8

4 SYSTEM REQUIREMENTS
4.1 INTRODUCTION 10
4.2 HARDWARE REQUIREMENTS
4.2.1 Hardware Specification 10
4.3 USER SYSTEM REQUIREMENTS 11
4.4 SOFTWARE REQUIREMENTS
4.4.1 Software Specification 11
4.5 MODULES
4.5.1 Open CV 12
4.5.2 Face Recognition
4.5.3 Smtp Lib
4.5.4 Date & Time
4.5.5 Num Py
4.5.6 MySQL
4.5.7 CSV

5 SOFTWARE REQUIREMENT SPECIFICATION


5.1 INTRODUCTION 19
5.2 FUNCTIONAL REQUIREMENTS
MODULE TRACEABILITY 20
5.2.1 Data Collection
5.2.2 Data Prepossessing
5.3 USECASE DIAGRAM 21
5.4 CLASS DIAGRAM 22
5.5 ACTIVITY DIAGRAM 23

iii
5.6 NON-FUNCTION REQUITMENTS
5.6.1 Performance
5.6.2 Security
5.6.3 Usability 24
5.6.4 Availability
5.6.5 Maintainability
5.6.6 Integration

6 SOFTWARE DESIGN
6.1 INTRODUCTION 26
6.2 MODULE DISCRIPTION
6.2.1 Face Detection Module
6.2.2 Face Recognition Module
6.2.3 Attendance Tracking Module
6.2.4 User Interface Module 27
6.2.5 Data Storage Module
6.2.6 Image Pre Processing Module
6.2.7 Configuration Module
6.2.8 Security Module
6.3 ARCHITECTURE DIAGRAM 34
6.4 PSEUDOCODE
6.4.1 Face Detection 35
6.4.2 Face Recognition

7 SOFTWARE TEST DESCRIPTION


7.1 INTRODUCTION 36
7.2 SOFTWARE TEST CASES DESCRIPTION 36
7.3 TEST CASES 39
7.4 INTEGRATION TESTING 40
7.5 SYSTEM TESTING 41

8 8.1 INSTALLATION 42
8.2 CODING 48
8.3 CODING STANDARDS
8.3.1 Coding Style Guidelines 49
8.4 CODE IMPLEMENTATION 51

9 RESULTS & DISCUSSIONS


9.1 RESULTS 61
9.2 DISCUSSIONS 61

10 CONCLUSION & FUTURE SCOPE


10.1 CONCLUSION 64
10.2 FUTURE SCOPE 65

REFERENCE
CONFERENCE CERTIFICATE
CONFERENCE PAPER

iv
LIST OF FIGURES

LIST OF FIGURES NAME OF THE FIGURE PAGE NO


5.3 USECASE DIAGRAM 21
5.4 CLASS DIAGRAM 22
5.5 ACTIVITY DIAGRAM 23
6.2 MODULE DISCRIPTION 27
6.3 ARCHITECTURE DIAGRAM 34

LIST OF ABBREVIATION

S.NO ABBREVIATION EXPANSION


1 FR Face recognition
2 OCR Optical character recognition
3 ROI Region of interest
4 SVM Support Vector Machine
5 HOG Histogram of Oriented Gradients
6 LBP Local Binary Pattern
7 PCA Principal Component Analysis
8 DNN Deep Neural Network
9 CNN Convolutional Neural Network
10 FCN Fully Convolutional Network

v
CHAPTER 1
1.1 INTRODUCTION

During this era of technology and automation we are still using the same
old ways of classroom management. The most important thing in classroom is
attendance which is directly linked to the academic performance of the students.
Recently, some of students are busy with better during lectures only when there
is massive classroom control (Research Gate, 2018). The more efficient the
attendance system the more is class participation and learning. In the past we were
using techniques like roll numbering calling and signing against a particular roll
number. These methods carry a high chance of proxy and are time consuming.
We came across the idea of automating this process to through modern day
technologies to get a well maintained and disciplined classroom. Facial
recognition system along with suitable hardware and software will help meet the
goals of this project. Facial recognition system is a derived innovation of image
processing. Image processing deals with the extraction of needy data that can be
related to digital image and in technology advancement it plays a unique role. Our
core focus will be on receiving digital images and then making use of programs
and algorithms to get useful Information out of it. As the pictorial information is
fed the image processing work on it and make it useful human interpretation. That
information from image processing will play a great role and help in various
walks of life where it could be implemented. The applications of image
processing are vast and can be applied in most scenarios where imaging data
could be related to pre-determined algorithms. It was an advanced application of
image processing and also is the core basis for our project. Our facial structure
was a typical example of a multidimensional structure and need some recognition
from advanced computational analysis.
1.2 PROBLEM STATEMENT:

Traditional attendance systems often rely on manual processes like signing


attendance sheets or using RFID cards. These processes are prone to errors and
can be time-consuming. Moreover, in the current scenario, with the need for
social distancing due to COVID-19, touch-based attendance systems are not ideal.
To overcome these challenges, a real-time face detection attendance system using
OpenCV can be developed.

1.3 SIGNIFICANCE:

The proposed system can automate the attendance process and eliminate
the need for manual entry or touch-based attendance systems. The real-time face
detection feature can ensure accurate attendance tracking and reduce the
possibility of proxies. The use of OpenCV can make the system cost-effective
and accessible to a wide range of users. Additionally, the system can be used in
various settings like schools, colleges, offices, and other organizations. This
system can save time, reduce errors, and improve the overall efficiency of the
attendance process.

1.4 SCOPE OF THE PROJECT:

1.4.1 Real-time face detection using OpenCV:

OpenCV is an open-source computer vision library that can be used to


detect and recognize faces in real-time. The system can use a camera to capture
live footage and process it using OpenCV to detect faces.

Face recognition and attendance marking: The system can be trained to


recognize faces using techniques like deep learning or machine learning.
Record keeping: The system can maintain a record of attendance for each
individual in a database or file. The record should include details like the date,
time, and class.

Attendance calculation: The system can calculate the attendance percentage


for each individual based on the number of classes attended. This can be done by
dividing the number of classes attended by the total number of classes held.

Automated attendance sheet generation: The system can generate an


attendance sheet in CSV format that includes the attendance details for each
individual.

Email integration: The attendance sheet can be sent as a CSV file through
email to the respective individuals, including students and faculty. This can be
done using an email API or SMTP server.

User authentication: The system can be designed with user authentication


features to ensure only authorized individuals can access the attendance data. This
can be done using techniques like username and password authentication or two-
factor authentication.

Overall, the system can help automate the attendance process, save time,
reduce errors, and improve efficiency. Additionally, it can provide real-time
attendance monitoring and be integrated with existing student information
systems for seamless attendance management.
CHAPTER 2
2.1 LITRATURE SURVEY:

Title: Smart Attendance System using QR code


Authors: Asri Nuhi, Agon Memeti, Florinda Imeri, Betim Cico
Published In: 2020
The paper proposes a smart attendance system that uses QR codes to mark
attendance in educational institutions and organizations. The authors review the
literature on attendance monitoring systems and highlight the advantages and
disadvantages of each. They introduce their proposed system, which comprises a
mobile application that generates unique QR codes for each student and a web
application that records the attendance data. The system features real-time
monitoring and automatic notification of absentees.

Title: Centre for Telecommunication Research and Innovation, Universiti


Teknikal Malaysia Melaka
Authors: M.A. Meor, M.H. Misran, M.A. Othman, M.M. Ismail, H.A. Sulaiman,
A. Salleh, N. Yusop
Published in: 2014
The Centre for Telecommunication Research and Innovation is a research
center located in the Faculty of Electronics and Computer Engineering at
Universiti Teknikal Malaysia Melaka. The center was established to facilitate
research and development in the field of telecommunications, particularly in the
areas of wireless communication and networking.

The center's research activities focus on various aspects of wireless


communication, including antenna design, signal processing, and network
protocols. The center has a team of experienced researchers and engineers who
work on various research projects in collaboration with industry partners and other
academic institutions.

Title: Design and Implementation of Iris Recognition Based Attendance


Management System
Authors: Amena Khatun, A.K.M Fazlul Haque, Sabbir Ahemad, Mohammad
Rahman
Published in: ICEEICT Jahangirnagar University, Bangladesh, 2015.
The paper describes the design and implementation of an iris recognition-
based attendance management system. The authors review the literature on
attendance management systems and highlight the importance of biometric
authentication in ensuring accurate attendance tracking. They introduce their
proposed system, which uses iris recognition technology to authenticate students
and record their attendance.

The system comprises a camera that captures images of the student's iris
and a software program that processes the images and matches them against a
database of enrolled students. The system features real-time monitoring and
automatic notification of absentees. The authors present the results of their
evaluation of the system's performance, including the accuracy of the attendance
data and user satisfaction.

Title: Real-Time Smart Attendance System using Face Recognition Techniques


Authors: Shreyak Sawhney, Karan Kacker, Samyak Jain, Shailendra Narayan
Singh, Rakesh Garg
Published in: Amity University Uttar Pradesh, Noida, 2019.

The paper presents a real-time smart attendance system that uses face
recognition techniques to track attendance in educational institutions and other
organizations. The authors review the literature on attendance management
systems and highlight the advantages and limitations of various techniques. They
introduce their proposed system, which comprises a camera that captures images
of the students' faces and a software program that processes the images and
matches them against a database of enrolled students.

The system features real-time monitoring and automatic notification of


absentees. The authors present the results of their evaluation of the system's
performance, including the accuracy of the attendance data and user satisfaction.

Title: LBPH based Improved face recognition at low Resolution


Author: Awais Ahmed
Published in: UNIVERSITY OF ELECTRONIC SCIENCE AND
TECHNOLOGY OF CHINA 2018 IEEE

The paper presents a novel approach for improving face recognition at low
resolution using the Local Binary Pattern Histogram (LBPH) technique. The
author reviews the literature on face recognition techniques and highlights the
challenges posed by low-resolution images. The proposed approach aims to
address these challenges by improving the accuracy of face recognition in low-
resolution images.

The approach uses the LBPH technique to extract features from the low-
resolution images and applies a two-step classification process to match the
images against a database of enrolled faces. The first step involves comparing the
extracted features with the features of the enrolled faces, and the second step
involves applying a support vector machine (SVM) classifier to the matched
features.
CHAPTER 3
SYSTEM ANALYSIS

3.1 INTRODUCTION:
Systems analysis is "the process of studying a procedure or business in
order to identify its goals and purposes and create systems and procedures that
will achieve them in an efficient way". Another view sees system analysis as a
problem-solving technique that breaks down a system into its component pieces
for the purpose of the studying how well those component parts work and interact
to accomplish their purpose. It is a process of collecting and interpreting facts,
identifying the problems, and decomposition of a system into its components.

System analysis is conducted for the purpose of studying a system or its


parts in order to identify its objectives. It is a problem-solving technique that
improves the system and ensures that all the components of the system work
efficiently to accomplish their purpose

3.2 EXISTING SYSTEM:

3.2.1 Fingerprint Based recognition system:


In the Fingerprint based existing attendance system, aportable fingerprint
device need to be configured with the students fingerprint earlier.

Later either during the lecture hours or before, the student needs to record
the finger print on the configured device to ensure their attendance for the day.

3.2.2 Iris Based Recognition System:


In the Iris based student attendance system, the student needs to stand in
front of a camera, so that the camera will scan the Iris of the student.
The scanned iris is matched with data of student stored in the database and
the attendance on their presence needs be updated.

3.2.3 Face Based Recognition System:


The facial recognition technology can be used in recording the attendance
through a high-resolution digital camera.

3.3 PROPOSED SYSTEM:

Hardware: A camera, computer, and display device are required for the
system. The camera should be capable of capturing live footage, and the computer
should have enough processing power to run the face detection algorithm.

Software: The system can be developed using Python programming


language and the OpenCV library for face detection and recognition. The
attendance data can be stored in a database or file, and a web-based interface can
be developed for user access.

Face detection and recognition: The system can use OpenCV's pre-
trained models for face detection and recognition or can be trained on a custom
dataset. Once a face is detected, the system can compare it with pre-registered
faces and mark attendance for that individual.

Record keeping: The system can maintain a record of attendance for each
individual, including details like the date, time, and class. The attendance data can
be stored in a database or file and can be accessed through a web-based interface.

Attendance calculation: The system can calculate the attendance


percentage for each individual based on the number of classes attended. This can
be done by dividing the number of classes attended by the total number of classes
held.
Automated attendance sheet generation: The system can generate an
attendance sheet in CSV format that includes the attendance details for each
individual. This sheet can be automatically updated each time attendance is
marked.

Email integration: The attendance sheet can be sent as a CSV file through
email to the respective individuals, including students and faculty. This can be
done using an email API or SMTP server.

User authentication: The system can be designed with user authentication


features to ensure only authorized individuals can access the attendance data. This
can be done using techniques like username and password authentication or two-
factor authentication.
CHAPTER 4
SYSTEM REQUIREMENTS

4.1 INTRODUCTION:

A System Requirements is a document or set of documentation that


describes the features and behaviour of a system or software application. System
requirements are a broad and also narrow detailed statement that the customer
makes in order to achieve their requirements. The statement should clearly explain
what the customer exactly wants and how they want it. A customer’s need might
be to satisfy a contract, solve a problem, achieve an objective, meet a standard, or
to meet any other guidelines of the project. System requirements will always vary
depending on the project and no two systems would have identical requirements.

4.2 HARDWARE REQUIREMENTS:

System: Core i5 and above


Hard Disk: 320 GB
RAM: 4 GB and above

4.2.1 Hardware Specification:

The most common set of requirements defined by any operating system or


software application is the physical computer hardware. It can be a desktop or a
laptop with operating systems windows 7 and above. Processors include Any Intel
or AMD x86-64 processor, AVX2 instruction set support is recommended with
Polyspace, 4 cores are recommended. RAM of 4 GB with Simulink, 8 GB is
required with Polyspace, 4 GB per core is recommended. No specific graphics
card is required. Hardware accelerated graphics card supporting OpenGL 3.3 with
1GB GPU memory is recommended.
4.4 USER SYSTEM REQUIREMENTS:
• Any personal Computer or Mobile
• Browser (Must be most modern browser which support ES6 syntax).

4.4 SOFTWARE REQUIREMENTS:


• Operating System: Windows 8 or Windows 10
• Language: Python
• Package – NumPy, Pandas, Streamlit etc.,
• Data set: Nut Diet, and food related datasets.
• Tools: Jupyter notebook, VS code, TensorFlow.

4.4.1 Software Specification:

VISUAL STUDIO CODE:

Visual Studio Code is a streamlined code editor with support for


development operations like debugging, task running, and version control. It aims
to provide just the tools a developer needs for a quick code-build-debug cycle and
leaves more complex workflows to fuller featured IDEs, such as Visual Studio
IDE.

PYTHON:

Python is an interpreted high-level programming


language for programming Python offers multiple options for developing GUI
(Graphical User Interface). Out of all the GUI methods, tkinter is the most
commonly used method. It is a standard Python interface to the Tk GUI toolkit
shipped with Python. Python with tkinter outputs the fastest and easiest way to
create the GUI applications. Creating a GUI using tkinter is an easy task.
4.5 MODULES:

4.5.1 Open CV:


OpenCV Python package provides various pre-trained models for face
detection and recognition. These models are based on the Haar cascades and Local
Binary Patterns (LBP) algorithms, which are efficient for detecting and
recognizing faces in real-time video streams.

The OpenCV package also provides various image processing functions


that can be used to pre-process the input images before face detection and
recognition. For instance, functions like image resizing, normalization, and
grayscale conversion can be used to enhance the quality of the input images and
improve the accuracy of the face detection and recognition process.

Moreover, the OpenCV package provides features for displaying the video
stream and drawing bounding boxes around detected faces in real-time. This
feature is useful for monitoring the face detection process and verifying the
accuracy of the recognition algorithm.

Overall, the OpenCV Python package provides a comprehensive set of


tools for real-time face detection and recognition. It allows developers to easily
implement complex computer vision algorithms in Python and provides a
powerful platform for developing applications in the fields of object recognition,
face recognition, and image processing.

OpenCV-Python is a library for computer vision programming in Python.


It is a wrapper around the popular open-source computer vision library OpenCV,
which provides access to a wide range of computer vision algorithms.
4.5.2 Face Recognition:
The face recognition package is an open-source Python library for face
recognition that is built on top of dlib, a popular C++ library for machine learning.
It provides a simple and easy-to-use interface for developers to perform face
recognition in their Python applications.

Some of the key features of the face_recognition package include:

Face detection: The package provides pre-trained models for face


detection that are based on the Histogram of Oriented Gradients (HOG) algorithm.
These models are optimized for speed and accuracy and can detect faces in real-
time video streams.

Face encoding: The package provides a function for encoding the face in
an image as a 128-dimensional vector. This encoding is based on a neural network
that is trained to extract features from faces and is highly accurate and robust to
variations in lighting, pose, and expression.

Face matching: The package provides a function for matching two face
encodings and determining whether they belong to the same person. This
matching is based on the Euclidean distance between the two encodings and is
highly accurate and reliable.

Integration with OpenCV: The face_recognition package can be easily


integrated with the OpenCV package to perform real-time face recognition in
video streams. The package provides functions for converting between OpenCV's
image format and the format used by the face_recognition package.
Overall, the face recognition package provides a powerful set of tools for
performing face recognition in Python applications. It is easy to use and highly
accurate, making it well-suited for the real-time face detection attendance system
using OpenCV.

4.5.3 Smtp Lib:


The smtplib package is a built-in Python library that provides an interface
to the Simple Mail Transfer Protocol (SMTP), which is used for sending emails.
It provides functions for connecting to an SMTP server, sending emails, and
handling errors that may occur during the email sending process.

To send an email using the smtplib package, the following steps need to be
taken:

• Create an SMTP object by specifying the SMTP server address and port
number.

• Login to the SMTP server using the login() function with a valid username
and password.

• Compose the email message using the Message() class and set the message
headers, such as To, From, Subject, etc.

• Send the email using the send_message() function with the Message object
as the argument.

• Close the SMTP connection using the quit() function.


The smtplib package provides a simple and efficient way to send emails
from Python programs. It supports various authentication methods, such as
PLAIN and LOGIN, and can be used with various email providers, such as Gmail,
Yahoo, and Outlook.
In the real-time face detection attendance system using OpenCV, the
smtplib package will be used to send an email containing the attendance sheet as
a CSV file to the specified email address. The attendance sheet will be generated
using Python's CSV module, which provides functions for reading and writing
CSV files.

4.5.4 Date & Time:

The datetime module is a built-in Python library that provides classes for
working with dates, times, and time intervals. The datetime module is used in the
real-time face detection attendance system using OpenCV to generate and record
timestamps for each face recognized in the video stream.

The datetime module provides several classes, including date, time,


datetime, timedelta, and tzinfo. These classes can be used to perform various
operations, such as arithmetic operations, formatting, parsing, and timezone
handling.

In the real-time face detection attendance system using OpenCV, the


datetime module will be used to generate timestamps for each face recognition
event. When a face is recognized, the current date and time will be recorded using
the datetime.now() function, which returns the current local date and time. The
recorded timestamps will be stored in a database or a CSV file, along with the
corresponding student's name and attendance status.
The datetime module provides functions for converting datetime objects to
string representations and vice versa. This feature is useful for formatting the
recorded timestamps in a human-readable format, such as "YYYY-MM-DD
HH:MM:SS". The strftime() function can be used to format datetime objects as
strings, while the strptime() function can be used to parse strings as datetime
objects.

Overall, the datetime module provides a powerful set of tools for working
with dates and times in Python. It is easy to use and highly versatile, making it
well-suited for the real-time face detection attendance system using OpenCV.

4.5.5 Num Py:


The NumPy (Numerical Python) module is a popular open-source library
used in scientific computing with Python. It provides support for large, multi-
dimensional arrays and matrices, as well as a collection of mathematical functions
to operate on these arrays. The NumPy module is used in the real-time face
detection attendance system using OpenCV to manipulate and process images.

The NumPy module provides a multi-dimensional array object called


ndarray, which can be used to represent and manipulate arrays of any
dimensionality. NumPy arrays are more efficient than Python lists for handling
large amounts of numerical data, as they are implemented in C and allow for fast,
element-wise operations.

In the real-time face detection attendance system using OpenCV, the


NumPy module will be used to manipulate the video stream frames and the facial
recognition data. The video stream frames will be represented as NumPy arrays,
which will allow for efficient processing using NumPy's built-in functions. The
facial recognition data, such as the detected faces and their corresponding
locations, will also be stored in NumPy arrays.

The NumPy module provides a wide range of mathematical functions, such


as arithmetic operations, statistical functions, and linear algebra operations. These
functions will be used in the real-time face detection attendance system using
OpenCV to perform various tasks, such as image resizing, filtering, and
thresholding.

Overall, the NumPy module is a powerful tool for scientific computing with
Python, and it is well-suited for the real-time face detection attendance system
using OpenCV. Its efficient handling of large numerical data, together with its
extensive collection of mathematical functions, makes it an essential part of many
computer vision projects.

4.5.6 MySQL:
MySQL is currently the most popular database management system
software used for managing the relational database. It is open-source database
software, which is supported by Oracle Company. It is fast, scalable, and an easy-
to-use database management system in comparison with Microsoft SQL Server
and Oracle Database. It is commonly used in conjunction with PHP scripts for
creating powerful and dynamic server-side or web-based enterprise applications.
It is developed, marketed, and supported by MySQL AB, a Swedish company,
and written in C programming language and C++ programming language. The
official pronunciation of MySQL is not the My Sequel; it is My Ess Que Ell.
However, you can pronounce it your way. Many small and big companies use
MySQL. MySQL supports many Operating Systems like Windows, Linux, Mac
OS, etc. with C, C++, and Java.
4.5.7 CSV:
The CSV (Comma Separated Values) module is a built-in Python library
that provides functionality for working with CSV files. CSV files are commonly
used for storing tabular data, where each row represents a record and each column
represents a field. The csv module is used in the real-time face detection
attendance system using OpenCV to store attendance data in a CSV file.

The csv module provides a variety of classes and functions for reading and
writing CSV files. The main classes are the reader and writer objects, which allow
for reading and writing CSV files, respectively. The reader and writer objects have
various methods for manipulating CSV data, such as reading and writing rows,
changing the delimiter, and handling quoted fields.

In the real-time face detection attendance system using OpenCV, the csv
module will be used to store attendance data in a CSV file. Each time a student is
recognized in the video stream, their name, attendance status, and timestamp will
be recorded in a row in the CSV file. The writer object will be used to write the
data to the CSV file, while the reader object will be used to read the data back for
analysis and reporting.

The csv module provides a simple and efficient way to store and process
tabular data in a text format. It is easy to use and can handle large amounts of data
efficiently. Overall, the csv module is a useful tool for data storage and
manipulation in the real-time face detection attendance system using OpenCV.
CHAPTER 5
SOFTWARE REQUIREMENT SPECIFICATION

5.1 INTRODUCTION:
Our project aims to solve this daily crisis by building a recipe recommendation
system. This system targets healthcare patients and people suffering from various
diseases like thyroid, anemia and so on, by suggesting them various nutritious
recipes which is based on certain factors like

1. The disease that the person currently has


2. The nutrition that they are focusing – e.g., Zinc, Iron etc.
3. The region that they belong.
4. The type of recipe – starters, main course, desserts etc.

Considering these aspects, our system recommends many nutritious recipes


that matches the individual’s health problems and their preferred nutrition and it
also suggests recipes based on special festive occasions. This model also makes
an analysis of the individual’s daily nutrition intake and updates them on what
could be improved to maintain their health.

5.2 FUNCTIONAL REQUIREMENTS:


Functional requirements may involve calculations, technical details, data
manipulation and processing, and other specific functionality that define what a
system is supposed to accomplish. Behavioural requirements describe all the
cases where the system uses the functional requirements, these are captured in
use cases.
MODULE TRACEABILITY:

5.2.1 Data Collection:

The initial step is to gather a dataset to accomplish this analysis. We have


used web scraping techniques to collect data from open source website
food.ndtv.com. We have used python libraries such as beautiful soup and requests
for this technique. Foods under each category such as cereals and pulses,
beverages etc is searched through the website and the content of the web page is
taken using beautiful soup library using html parser and the raw data of food items
and its description is taken and stored in a csv file.

5.2.2 Data Prepossessing:

In this module the collected raw dataset is loaded and cleaned using pandas
and NumPy. Duplicates values and null values are removed. There are several
techniques used for normalizing the dataset. Food items that can be consumed
for each disease are collected from official websites such as healthline.com
redcrossblood.org etc. Based on the information collected a separate column
called disease is added to the data set and each food is mapped to one or more
diseases. Similarly, nutrient, diet type, cuisine data is collected and columns are
added for each. Thus, Data is processed and required attributes are added to make
perfect datasets.
5.3 USECASE DIAGRAM:
5.4 CLASS DIAGRAM:

5.5 ACTIVITY DIAGRAM:


5.6 NON-FUNCTION REQUITMENTS:

The non-functional requirements for the real-time face detection


attendance system using OpenCV define how the system should perform and
operate, rather than what the system should do. These requirements include
factors such as performance, reliability, security, scalability, usability,
availability, compatibility, maintainability, performance under load, and
integration with other systems.

5.6.1 Performance:
Performance is a key requirement for the system, as it should be able to
detect faces in real-time with minimal delay, to ensure accurate attendance
tracking. Reliability is also important, with high accuracy in detecting faces and
tracking attendance.

5.6.2 Security:
Security is a critical requirement, as the system should protect the privacy
of the students by encrypting and securely storing the facial recognition data.
Scalability is another important requirement, as the system should be designed to
handle a large number of students and video streams, and be easily scalable as the
number of students and streams increase.

5.6.3 Usability:
Usability is also important, as the system should be easy to use, with a
simple and intuitive user interface. The attendance data should be presented in a
clear and organized manner.
5.6.4 Availability:
Availability is a key requirement, as the system should be available 24/7,
with minimal downtime for maintenance or upgrades. Compatibility is also
important, as the system should be compatible with different operating systems
and platforms, to ensure flexibility in deployment.

5.6.5 Maintainability:
Maintainability is another requirement, as the system should be easy to
maintain and update, with clear documentation and well-organized code.
Performance under load is also important, as the system should be able to handle
a large number of students and video streams, without compromising
performance or accuracy.

5.6.6 Integration:
Integration with other systems is a requirement, as the system should be
able to integrate with other systems, such as student management software or
email clients, to provide a seamless and efficient attendance tracking solution. All
of these non-functional requirements will help ensure that the real-time face
detection attendance system using OpenCV is reliable, secure, scalable, and easy
to use.
CHAPTER 6

SOFTWARE DESIGN

6.1 INTRODUCTION:

The software design for the real-time face detection attendance monitoring
system began with a careful analysis of the requirements. These included not only
the need for accuracy and speed, but also the need for a user-friendly interface
that would make it easy for administrators to view attendance records and track
attendance trends.

After identifying the requirements, the next step was to choose a face
detection algorithm that could meet these requirements. Haar cascades and Viola-
Jones algorithm were considered, but ultimately, a Convolutional Neural Network
(CNN) was selected for its high accuracy and ability to handle large datasets.

To train the CNN, a large dataset of facial images was collected and pre-
processed using techniques such as normalization and data augmentation. The
resulting dataset was then used to train the CNN and fine-tune its parameters for
maximum accuracy.

Finally, the user interface was designed with ease of use in mind, featuring
a clean and intuitive layout that allows administrators to quickly access attendance
data and view trends over time. With this software design, the real-time face
detection attendance monitoring system is poised to revolutionize attendance
tracking in a variety of industries.
6.2 MODULE DISCRIPTION:

LIST OF MODULES:
• IMAGE PRE PROCESSING MODULE
• FACE DETECTION MODULE
• FACE RECOGANATION MODULE
• ATTENDENCE TRACKING MODULE
• DATA STORAGE MODULE
• USER INTERFACE MODULE
• EMAIL NOTIFICATION MODULE
• CONFIGURATION MODULE
• SECURITY MODULE
6.2.1 Image Pre Processing Module:
The image pre-processing module in the real-time face detection attendance
system using OpenCV is responsible for preparing input images for face detection
and recognition.

This module typically includes several pre-processing techniques, such as


image resizing, noise reduction, and contrast enhancement, that help to improve
the accuracy and reliability of face detection and recognition.

Image resizing is used to standardize the size of input images, which can
help to reduce processing time and improve accuracy. Noise reduction techniques
such as blurring or denoising can be used to remove unwanted artifacts from input
images, such as camera noise or background clutter. Contrast enhancement
techniques such as histogram equalization or adaptive histogram equalization can
be used to enhance the visibility of facial features and improve the accuracy of
face detection and recognition.

Overall, the image pre-processing module plays an important role in


improving the accuracy and reliability of face detection and recognition, by
preparing input images in a way that is optimized for the specific requirements of
the system.

6.2.2 Face Detection Module:


The real-time face detection attendance system using OpenCV consists of
several modules that work together to provide a comprehensive attendance
tracking solution. The face detection module is responsible for detecting faces in
real-time video streams using OpenCV's face detection algorithm. The face
recognition module recognizes the faces detected in the video stream, and matches
them with pre-registered faces in the system. The attendance tracking module
tracks the attendance of each student, based on the faces detected and recognized
in the video stream.

6.2.3 Face Recognition Module:


The face recognition module in the real-time face detection attendance
system using OpenCV is responsible for recognizing the faces detected in the
video stream and matching them with pre-registered faces in the system. This
module uses OpenCV's face recognition algorithms to identify the unique facial
features of each individual, and compares these features with those of registered
faces in the system.

To achieve accurate face recognition, this module typically requires a large


database of registered faces, along with additional information such as names and
IDs. The face recognition module then compares the facial features of the faces
detected in the video stream with those in the database, and generates a match
score for each comparison.

If the match score exceeds a certain threshold, the face recognition module
considers the detected face to be a match with a registered face, and records the
attendance of the corresponding individual. The module may also update the
attendance records of previously detected faces, in case the same individual is
detected multiple times in the same video stream.
Overall, the face recognition module plays a crucial role in accurately
tracking attendance in real-time, by identifying and matching faces with registered
individuals in the system.

6.2.4 Attendance Tracking Module:


The attendance tracking module in the real-time face detection attendance
system using OpenCV is responsible for keeping track of the attendance of each
student in real-time, based on the faces detected and recognized in the video
stream.

When a face is detected and recognized, the attendance tracking module


checks whether the corresponding student has been marked as present or absent.
If the student has not been marked as present, the module marks them as present
and updates their attendance record. If the student has already been marked as
present, the module does not update their attendance record.

The attendance tracking module may also include additional functionality,


such as generating reports on attendance statistics for individual students, classes,
or time periods. It may also allow faculty or administration to view the attendance
records of individual students or entire classes, and to edit attendance records if
necessary.

Overall, the attendance tracking module is a crucial component of the real-


time face detection attendance system, allowing faculty or administration to
accurately track attendance in real-time and monitor attendance statistics over
time.

6.2.5 Data Storage Module:


The data storage module in the real-time face detection attendance system
using OpenCV is responsible for managing the storage of attendance data and
other system-related information.

This module typically includes a database management system (DBMS)


that stores and retrieves attendance records, student information, and other
relevant data. The DBMS may use a relational database such as MySQL or
PostgreSQL, or a NoSQL database such as MongoDB, depending on the specific
requirements of the system.

The data storage module also includes functions for accessing and
manipulating data in the database, such as adding new attendance records,
updating existing records, and querying attendance data for individual students,
classes, or time periods. It may also include functions for backing up and restoring
data, to prevent data loss in case of system failure or other issues.

Overall, the data storage module is a critical component of the real-time


face detection attendance system, as it ensures that attendance data and other
important information is stored securely and can be easily accessed and
manipulated by other modules in the system.

6.2.6 User Interface Module:


The user interface module in the real-time face detection attendance system
using OpenCV is responsible for providing a graphical user interface (GUI) for
the system, allowing faculty or administration to view attendance data and
configure system settings.

The user interface may include a dashboard or main screen that displays
attendance data in real-time, such as the number of students present and absent,
and the attendance percentage for each class. It may also include a calendar or
timetable view that displays attendance data for individual classes or time periods.

The user interface module may also allow faculty or administration to


configure system settings, such as email credentials, face recognition parameters,
and database connection settings. It may include forms or dialog boxes for
entering and editing attendance records, and for registering new faces or students
in the system.

Overall, the user interface module provides an intuitive and user-friendly


way for faculty or administration to interact with the real-time face detection
attendance system, making it easier to track attendance and manage system
settings.

6.2.7 Configuration Module:


The configuration module in the real-time face detection attendance system
using OpenCV is responsible for managing system configuration settings, such as
email credentials, database connection settings, and face recognition parameters.

This module typically includes functions for reading and writing


configuration settings from a configuration file, such as a JSON or YAML file,
and for validating configuration settings to ensure that they are in the correct
format and contain all the required information.

The configuration module may also include functions for dynamically


updating system configuration settings during runtime, such as changing the face
recognition parameters or the email credentials.

Overall, the configuration module is an important component of the real-


time face detection attendance system, as it enables system administrators to
customize and optimize the system based on their specific requirements and
preferences.
6.2.8 Security Module:
The security module in the real-time face detection attendance system using
OpenCV is responsible for ensuring the security and integrity of system data and
processes.

This module typically includes several security measures, such as user


authentication and authorization, data encryption, and access control, that help to
prevent unauthorized access, modification, or deletion of system data.

User authentication and authorization involves verifying the identity of


users who access the system, and determining the level of access they have to
system data and functionality. This can be implemented using username/password
authentication, multi-factor authentication, or other techniques.

Data encryption is used to protect sensitive data, such as email credentials


or attendance records, from unauthorized access by encrypting the data using a
secure encryption algorithm. Access control techniques such as role-based access
control or attribute-based access control can be used to ensure that only authorized
users can access and modify system data.
6.3 ARCHITECTURE DIAGRAM:

The proposed system is designed to automate the attendance tracking


process using image processing and face recognition techniques. It consists of a
camera that captures live video streams of students, which are processed using
image processing techniques to remove any noise or background interference. The
processed video streams are then classified to detect and identify the faces of
students in real-time. The system compares the identified faces with a database of
images stored in an image folder. If a match is found, the system recognizes the
student's name and marks attendance accordingly. On the other hand, if the
identified face does not match with any of the images in the image folder, the
system marks the attendance as "unknown". The system is controlled through a
web page interface that allows the user to start or stop the camera and provides a
mail button to send attendance records via email. The proposed system provides
an efficient and reliable way to track attendance and can potentially save a
significant amount of time and effort in the manual attendance tracking process.
6.4 PSEUDOCODE:

6.4.1 Face Detection:


INPUT:
A digital image or video stream containing one or more faces.

OUTPUT:
The location and size of each face within the image.

PROCESS:
• First, we use a pre-trained face detection algorithm to identify potential faces
within the image or video stream.
• Next, we apply non-maximum suppression to remove overlapping bounding
boxes around the detected faces.
• Finally, we output the location and size of each remaining bounding box as the
detected face regions.

6.4.2 Face Recognition:


INPUT:
A set of face images for each person to be recognized, as well as a test image
containing an unknown face.

OUTPUT:
The name or ID of the person in the test image, or "unknown" if no match is found.
PROCESS:
• First, we pre-process each face image using normalization techniques to ensure
consistency across all images.
• Next, we extract a feature vector from each face image using a pre-trained deep
neural network.
• Then, we train a machine learning model on the feature vectors from the training
set to learn to recognize each individual's face.
• Finally, we compare the feature vector extracted from the test image to those
from the training set, and assign the test image to the individual with the closest
match based on some similarity metric, such as Euclidean distance or cosine
similarity. If no match is found above a certain threshold, we output "unknown".
CHAPTER 7
SOFTWARE TEST DESCRIPTION
7.1 INTRODUCTION:

This chapter is about the software test cases and possible output along with
the expected output.

7.2 SOFTWARE TEST CASES DESCRIPTION:

Testing is performed to identify errors. It is used for quality assurance.


Testing is an integral part of the entire development and maintenance process. The
goal of the testing during this phase is to verify that the specification has been
accurately and completely incorporated into the design, as well as to ensure the
correctness of the design itself. For example, the design must not have any logic
faults in it. If it is not detected before coding commences, the cost of fixing the
faults will be considerably higher as reflected. Detection of design faults can be
achieved by means of inspection as well as walkthrough. Testing is one of the
important steps in the software development phase.

TEST CASE DESCRIPTION:

Test Case Name: Face Detection Accuracy Test

Description: Verify that the system can accurately detect faces in input images
and video streams.

Test Steps:

• Input a set of test images and video streams with varying lighting
conditions, poses, and orientations.
• Verify that the system can detect faces in each input image or frame.
• Verify that the system can correctly identify and label each detected face.
Test Case Name: Face Recognition Accuracy Test

Description: Verify that the system can accurately recognize and match faces to
the correct individuals.

Test Steps:

• Input a set of test images and video streams with known individuals and
their corresponding identities.
• Verify that the system can recognize and match each individual in the input
images or frames.
• Verify that the system can accurately calculate the attendance percentage
for each individual based on their presence in the input streams.

Test Case Name: User Interface Test

Description: Verify that the user interface of the system is intuitive and easy to
use.

Test Steps:

• Input a set of test images and video streams into the system.
• Verify that the user interface displays the input streams and the detected
faces in real-time.
• Verify that the user interface displays the attendance sheet in a clear and
organized manner.
• Verify that the user interface allows the user to configure the system
settings and export the attendance sheet as a CSV file.
Test Case Name: Email Functionality Test

Description: Verify that the system can send attendance sheets as CSV files to
designated email addresses.

Test Steps:

• Configure the system with valid email credentials and recipient email
addresses.
• Input a set of test images and video streams into the system and generate
the attendance sheet.
• Verify that the system can send the attendance sheet as a CSV file to the
designated email addresses.
• Verify that the attendance sheet is correctly formatted and contains accurate
attendance data.

Test Case Name: Performance Test

Description: Verify that the system can handle a large number of input streams
and process them in real-time.

Test Steps:

• Input a set of test images and video streams with a high volume of faces
and varying lighting conditions.
• Increase the number of input streams to a level that simulates real-world
usage.
• Verify that the system can process the input streams in real-time and
accurately detect and recognize faces.
• Monitor the system resource utilization, such as CPU and memory usage,
and ensure that they are within acceptable limits.
7.3 TEST CASES:
MODULE TESTCASE TEST EXPECTED ACTUAL STATUS
NAME DESCRIPTION OUTPUT OUTPUT
Face detection Face Verify accurate System detects System detects Pass
Detection face detection faces with high faces with high
Accuracy Test accuracy and accuracy and
labels them labels them
correctly correctly
Face Face Verify accurate System System accurately pass
Recognition Recognition face recognition accurately matches detected
Accuracy Test matches faces with known
detected faces identities and
with known calculates
identities and attendance
calculates percentage
attendance correctly
percentage
correctly
User Interface User Interface Verify intuitive User interface User interface pass
Test user interface displays input displays input
streams and streams and
attendance sheet attendance sheet in
in a clear and a clear and
organized organized manner,
manner, and and allows for
allows for easy easy configuration
configuration and export
and export
Image Pre- Performance Verify system System can System can pass
processing Test performance with process a large process a large
high volume of number of input number of input
faces streams in real- streams in real-
time with high time with high
accuracy, while accuracy, while
maintaining maintaining
acceptable acceptable
resource resource
utilization levels utilization levels
Data Storage Email Verify attendance System sends System sends pass
Functionality sheet email attendance sheet attendance sheet
Test functionality as a CSV file to as a CSV file to
designated designated email
email addresses, addresses, with
with accurate accurate
attendance data attendance data
and formatting and formatting

Configuration Verify accurate System allows System allows for pass


configuration for accurate accurate
settings configuration of configuration of
face recognition face recognition
and attendance and attendance
tracking settings tracking settings

Security Verify system System System pass


security implements implements
appropriate appropriate
security security measures
measures to to protect user
protect user data data and prevent
and prevent unauthorized
unauthorized access
access

7.4 INTEGRATION TESTING:

Integration testing is a level of software testing where individual units


components are combined and tested as a group. The purpose of this level of
testing is to expose faults in the interaction between integrated units. Test drivers
and test stubs are used to assist in Integration Testing.

It occurs after unit testing and before validation testing. Integration testing
takes as its input modules that have been unit tested, groups them in larger
aggregates, applies tests defined in an integration test plan to those aggregates,
and delivers as its output the integrated system ready for system testing.

7.5 SYSTEM TESTING:


System testing is a level of testing that validates the complete and fully
integrated software product. The purpose of a system test is to evaluate the end-
to-end system specifications. Usually, the software is only one element of a larger
computer-based system. System testing is testing conducted on a complete
integrated system to evaluate the system's compliance with its specified
requirements.

System testing takes, as its input, all of the integrated components that have
passed integration testing. The purpose of integration testing is to detect any
inconsistencies between the units that are integrated together (called
assemblages). System testing seeks to detect defects both within the "inter-
assemblages" and also within the system as a whole. The actual result is the
behaviour produced or observed when a component or system is tested.
CHAPTER 8

IMPLEMENTATION

8.1 INSTALLATION:
VISUAL STUDIO CODE:
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. Secondly, accept the agreement and click on next. Thirdly, click on
"create a desktop icon" so that it can be accessed from the desktop and click on
Next. After that, click on the install button. Finally, after installation completes,
click on the finish button, and the visual studio code will open. By default,
VSCode installs under
C:\users{username}\AppData\Local\Programs\Microsoft VS Code.

PYTHON:
The installation procedure involves downloading the official Python .exe
installer and running it on your system. The version you need depends on what
you want to do in Python.

Open your web browser and navigate to the Downloads for Windows
section of the official Python website. Search for your desired version of Python.
At the time of publishing this article, the latest Python 3 release is version 3.7.3,
while the latest Python 2 release is version 2.7.16. Select a link to download either
the Windows x86-64 executable installer or Windows x86 executable installer.
The download is approximately 25MB. Run the Python Installer once
downloaded. Make sure you select the Install launcher for all users and Add
Python 3.7 to PATH checkboxes. The latter places the interpreter in the execution
path. For older versions of Python that do not support the Add Python to Path
checkbox, see Step 6. Select Install Now – the recommended installation options.
For all recent versions of Python, the recommended installation options include
Pip and IDLE. Older versions might not include such additional features. The next
dialog will prompt you to select whether to Disable path length limit. Choosing
this option will allow Python to bypass the 260-character MAX_PATH limit.
Effectively, it will enable Python to use long path names. The Disable path length
limit option will not affect any other system settings. Turning it on will resolve
potential name length issues that may arise with Python projects developed in
Linux.

NUMPY ON PYTHON:
The only prerequisite for installing NumPy is Python itself. NumPy can be
installed with conda, with pip, with a package manager on macOS and Linux, or
from source. Using pip, we can install NumPy with: pip install numpy

Also, when using pip, it’s good practice to use a virtual environment.

OPEN CV ON PYTHON:
OpenCV Python package provides various pre-trained models for face
detection and recognition. These models are based on the Haar cascades and Local
Binary Patterns (LBP) algorithms, which are efficient for detecting and
recognizing faces in real-time video streams.

The OpenCV package also provides various image processing functions


that can be used to pre-process the input images before face detection and
recognition. For instance, functions like image resizing, normalization, and
grayscale conversion can be used to enhance the quality of the input images and
improve the accuracy of the face detection and recognition process.
Moreover, the OpenCV package provides features for displaying the video
stream and drawing bounding boxes around detected faces in real-time. This
feature is useful for monitoring the face detection process and verifying the
accuracy of the recognition algorithm.

Overall, the OpenCV Python package provides a comprehensive set of


tools for real-time face detection and recognition. It allows developers to easily
implement complex computer vision algorithms in Python and provides a
powerful platform for developing applications in the fields of object recognition,
face recognition, and image processing.

OpenCV-Python is a library for computer vision programming in Python.


It is a wrapper around the popular open-source computer vision library OpenCV,
which provides access to a wide range of computer vision algorithms.

FACE RECOGANATION ON PYTHON:


The face recognition package is an open-source Python library for face
recognition that is built on top of dlib, a popular C++ library for machine learning.
It provides a simple and easy-to-use interface for developers to perform face
recognition in their Python applications.

Some of the key features of the face_recognition package include:

Face detection: The package provides pre-trained models for face


detection that are based on the Histogram of Oriented Gradients (HOG) algorithm.
These models are optimized for speed and accuracy and can detect faces in real-
time video streams.
Face encoding: The package provides a function for encoding the face in
an image as a 128-dimensional vector. This encoding is based on a neural network
that is trained to extract features from faces and is highly accurate and robust to
variations in lighting, pose, and expression.
Face matching: The package provides a function for matching two face
encodings and determining whether they belong to the same person. This
matching is based on the Euclidean distance between the two encodings and is
highly accurate and reliable.
Integration with OpenCV: The face_recognition package can be easily integrated
with the OpenCV package to perform real-time face recognition in video streams.
The package provides functions for converting between OpenCV's image format
and the format used by the face_recognition package.

Overall, the face recognition package provides a powerful set of tools for
performing face recognition in Python applications. It is easy to use and highly
accurate, making it well-suited for the real-time face detection attendance system
using OpenCV.

SMTP LIB ON PYTHON:


The smtplib package is a built-in Python library that provides an interface
to the Simple Mail Transfer Protocol (SMTP), which is used for sending emails.
It provides functions for connecting to an SMTP server, sending emails, and
handling errors that may occur during the email sending process.

• To send an email using the smtplib package, the following steps need to be
taken:
• Create an SMTP object by specifying the SMTP server address and port
number.
• Login to the SMTP server using the login() function with a valid username
and password.

• Compose the email message using the Message() class and set the message
headers, such as To, From, Subject, etc.

• Send the email using the send_message() function with the Message object
as the argument.

• Close the SMTP connection using the quit() function.

The smtplib package provides a simple and efficient way to send emails
from Python programs. It supports various authentication methods, such as
PLAIN and LOGIN, and can be used with various email providers, such as Gmail,
Yahoo, and Outlook.

In the real-time face detection attendance system using OpenCV, the


smtplib package will be used to send an email containing the attendance sheet as
a CSV file to the specified email address. The attendance sheet will be generated
using Python's CSV module, which provides functions for reading and writing
CSV files.

DATE & TIME ON PYTHON:


The datetime module is a built-in Python library that provides classes for
working with dates, times, and time intervals. The datetime module is used in the
real-time face detection attendance system using OpenCV to generate and record
timestamps for each face recognized in the video stream.
The datetime module provides several classes, including date, time,
datetime, timedelta, and tzinfo. These classes can be used to perform various
operations, such as arithmetic operations, formatting, parsing, and timezone
handling.

In the real-time face detection attendance system using OpenCV, the


datetime module will be used to generate timestamps for each face recognition
event. When a face is recognized, the current date and time will be recorded using
the datetime.now() function, which returns the current local date and time. The
recorded timestamps will be stored in a database or a CSV file, along with the
corresponding student's name and attendance status.

The datetime module provides functions for converting datetime objects to


string representations and vice versa. This feature is useful for formatting the
recorded timestamps in a human-readable format, such as "YYYY-MM-DD
HH:MM:SS". The strftime() function can be used to format datetime objects as
strings, while the strptime() function can be used to parse strings as datetime
objects.

Overall, the datetime module provides a powerful set of tools for working
with dates and times in Python. It is easy to use and highly versatile, making it
well-suited for the real-time face detection attendance system using OpenCV.

MYSQL ON PYTHON:
MySQL is currently the most popular database management system
software used for managing the relational database. It is open-source database
software, which is supported by Oracle Company. It is fast, scalable, and an easy-
to-use database management system in comparison with Microsoft SQL Server
and Oracle Database. It is commonly used in conjunction with PHP scripts for
creating powerful and dynamic server-side or web-based enterprise applications.
It is developed, marketed, and supported by MySQL AB, a Swedish company,
and written in C programming language and C++ programming language. The
official pronunciation of MySQL is not the My Sequel; it is My Ess Que Ell.
However, you can pronounce it your way. Many small and big companies use
MySQL. MySQL supports many Operating Systems like Windows, Linux, Mac
OS, etc. with C, C++, and Java.

CSV ON PYTHON:
The CSV (Comma Separated Values) module is a built-in Python library
that provides functionality for working with CSV files. CSV files are commonly
used for storing tabular data, where each row represents a record and each column
represents a field. The csv module is used in the real-time face detection
attendance system using OpenCV to store attendance data in a CSV file.

The csv module provides a variety of classes and functions for reading and
writing CSV files. The main classes are the reader and writer objects, which allow
for reading and writing CSV files, respectively. The reader and writer objects have
various methods for manipulating CSV data, such as reading and writing rows,
changing the delimiter, and handling quoted fields.

In the real-time face detection attendance system using OpenCV, the csv
module will be used to store attendance data in a CSV file. Each time a student is
recognized in the video stream, their name, attendance status, and timestamp will
be recorded in a row in the CSV file. The writer object will be used to write the
data to the CSV file, while the reader object will be used to read the data back for
analysis and reporting.
The CSV module provides a simple and efficient way to store and process
tabular data in a text format. It is easy to use and can handle large amounts of data
efficiently. Overall, the csv module is a useful tool for data storage and
manipulation in the real-time face detection attendance system using OpenCV.

8.2 CODING:
Once the design aspect of the application is finalized, the application enters
into the coding and testing phase. The coding phase brings the actual system into
action by converting the design of the application into the code in a given
programming language. Therefore, a good coding style has to be taken and
whenever changes are required, it should be easily screwed into the system.

8.3 CODING STANDARDS:


Coding standards are guidelines to programming that focuses on the
physical structure and appearance of the program. They make the code easier to
read, understand and maintain. This phase of the system actually implements the
blueprint developed during the design phase. The coding specification should be
in such a way that any programmer must be able to understand the code and can
bring about changes whenever felt necessary.

8.3.1 Coding Style Guidelines:

For Python, PEP 8 has emerged as the style guide that most projects adhere
to; it promotes a very readable and eye-pleasing coding style. Every Python
developer should read it at some point; here are the most important points
extracted for you:

• Use 4-space indentation and no tabs. The 4-space rule is not always
mandatory and can be overruled for continuation lines.

• Use docstrings: There are both single and multi-line docstrings that can be
used in Python. However, the single line comment fits in 1-line, triple
quotes are used in both cases. These are used to define a particular program
or define a particular function.

• Wrap lines so that they don’t exceed 79 characters: The Python standard
library is conservative and requires limiting lines to 79 characters. The lines
can be wrapped using parenthesis, brackets, and braces. They should be
used in preference to backslashes.

• Use of regular and updated comments are valuable to both the coders and
users: There are also various types and conditions that if followed can be
of great help from programs and user’s point of view. Comments should
form complete sentences. If a comment is a full sentence, its first word
should be capitalized, unless it is an identifier that begins with a lowercase
letter. In short comments, the period at the end can be omitted. In block
comments, there are more than one paragraphs and each sentence must end
with a period. Block comments and inline comments can be written
followed by a single ‘#’.

• Use Python’s default UTF-8 or ASCII encodings and not any fancy
encodings, if it is meant for an international environment.

• Use spaces around operators and after commas, but not directly inside
bracketing constructs.

• Naming Conventions: There are few naming conventions that should be


followed in order to make the program less complex and more readable. At
the same time, the naming conventions in Python are a bit of a mess, but
here are few conventions that can be followed easily. There is an overriding
principle that follows that the names that are visible to the user as public
parts of API should follow conventions that reflect usage rather than
implementation.

• Here are few other naming conventions: b (single lowercase letter), B (single
upper-case letter), lowercase, lower_case_with_underscores,
UPPERCASE, UPPER_CASE_WITH_UNDERSCORES, Capitalized
Words (or CamelCase). Capitalized_Words_With_Underscores

• In addition to these few leading or trailing underscores are also considered.


Examples:
single_leading_underscore: weak “internal use” indicator. E.g., from M
import * does not import objects whose name starts with an underscore.

• single_trailing_underscore_: used to avoid conflicts with Python keyword.


double_leading_underscore: when naming a class attribute, invokes name
mangling. (inside class FooBar,boo becomes _FooBarboo;).

• double_leading_and_trailing_underscore: “magic” objects or attributes that


live in user-controlled namespaces. E.g.init,importor file. Only use them as
documented.

• Characters that should not be used for identifiers: ‘l’ (lowercase letter el), ‘O’
(uppercase letter oh), or ‘I’ (uppercase letter eye) as single character
variable names as these are similar to the numerals one and zero.

• Don’t use non-ASCII characters in identifiers if there are only the slightest
chance people speaking a different language will read or maintain the code.
• Name your classes and functions consistently: The convention is to use
CamelCase for classes and lower_case_with_underscores for functions and
methods. Always use self as the name for the first method argument.

• While naming the function of methods always use self for the first argument
to instance methods and class for the first argument to class methods. If a
functions argument name matches with reserved words then it can be
written with a trailing comma. For e.g., class_

8.4 CODE IMPLEMENTATION:

import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime,timedelta
from flask import Flask, render_template, request
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication

app = Flask(_name_)
start_time = None
elapsed_time = 0
max_time = 60
path = 'ImagesAttendance'
images = []
classnames = []
mylist = os.listdir(path)
print(mylist)
for cl in mylist:
curimg = cv2.imread(f'{path}/{cl}')
images.append(curimg)
classnames.append(os.path.splitext(cl)[0])
print(classnames)

def findencodings(images):
encodelist=[]
for img in images:
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
encode = face_recognition. face encodings(img)[0]
encodelist.append(encode)
return encodelist

def markAttendance(name):
with open('Attendance.csv','r+') as f:
mydatalist=f.readlines()
namelist=[]
for line in mydatalist:
entry=line.split(',')
namelist.append(entry[0])
if name not in namelist:
now=datetime.now()
dtstring=now.strftime('%H:%M:%S')
f.writelines(f'\n{name},{dtstring}')
def markAttendance1(name):
with open('endtime.csv','r+') as f:
mydatalist=f.readlines()
namelist=[]
for line in mydatalist:
entry=line.split(',')
namelist.append(entry[0])
if name not in namelist:
now=datetime.now()
dtstring=now.strftime('%H:%M:%S')
f.writelines(f'\n{name},{dtstring}')

encodelistknown = findencodings(images)
print('Encoding complete')
cap = cv2.VideoCapture(0)

@app.route("/")
def index():
return render_template("index.html")

@app.route('/start', methods=['POST'])
def start():
global cap
cap.release()
cv2.destroyAllWindows()

# Wait for 1 minute and detect faces again


time_end = datetime.now() + timedelta(minutes=1)
while datetime.now() < time_end:
# Reinitialize the video capture object
cap = cv2.VideoCapture(0)

# Load the known face encodings


encodelistknown = findencodings(images)
print('Encoding complete')

# Loop over the frames from the video stream


while datetime.now() < time_end:
success, img = cap.read()
if not success:
break
imgs = cv2.resize(img, (0, 0), None, 0.25, 0.25)
imgs = cv2.cvtColor(imgs, cv2.COLOR_BGR2RGB)
facescurframe = face_recognition.face_locations(imgs)
encodecurframe = face_recognition.face_encodings(imgs, facescurframe)

for encodeface, faceloc in zip(encodecurframe, facescurframe):


matches = face_recognition.compare_faces(encodelistknown,
encodeface)
facedis = face_recognition.face_distance(encodelistknown,
encodeface)
matchindex = np.argmin(facedis)

if matches[matchindex]:
name = classnames[matchindex].upper()
y1, x2, y2, x1 = faceloc
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(img, name, (x1 + 6, y2 - 6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance(name)
# else:
# # If the face does not match with the known faces, print "No Match"
on the screen
# y1, x2, y2, x1 = faceloc
# y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
# cv2.rectangle(img, (x1, y1), (x2, y2), (0, 0, 255), 2)
# cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 0, 255), cv2.FILLED)
# cv2.putText(img, "No Match", (x1 + 6, y2 - 6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)

cv2.imshow('webcam', img)
if cv2.waitKey(1) == ord('q') or datetime.now() >= time_end:
break

# Release the camera and close all windows


cap.release()
cv2.destroyAllWindows()
return "Face detection and attendance monitoring system stopped."

@app.route('/stop', methods=['POST'])
def stop():
global cap
cap.release()
cv2.destroyAllWindows()

# Wait for 1 minute and detect faces again


time_end = datetime.now() + timedelta(minutes=1)
while datetime.now() < time_end:
# Reinitialize the video capture object
cap = cv2.VideoCapture(0)

# Load the known face encodings


encodelistknown = findencodings(images)
print('Encoding complete')

# Loop over the frames from the video stream


while datetime.now() < time_end:
success, img = cap.read()
if not success:
break
imgs = cv2.resize(img, (0,0), None, 0.25, 0.25)
imgs = cv2.cvtColor(imgs, cv2.COLOR_BGR2RGB)
facescurframe = face_recognition.face_locations(imgs)
encodecurframe = face_recognition.face_encodings(imgs, facescurframe)

for encodeface, faceloc in zip(encodecurframe, facescurframe):


matches = face_recognition.compare_faces(encodelistknown,
encodeface)
facedis = face_recognition.face_distance(encodelistknown,
encodeface)
matchindex = np.argmin(facedis)
if matches[matchindex]:
name = classnames[matchindex].upper()
y1, x2, y2, x1 = faceloc
y1, x2, y2, x1 = y1*4, x2*4, y2*4, x1*4
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(img, (x1, y2-35), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(img, name, (x1+6, y2-6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
markAttendance1(name)
# else:
# # If the face does not match with the known faces, print "No Match"
on the screen
# y1, x2, y2, x1 = faceloc
# y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
# cv2.rectangle(img, (x1, y1), (x2, y2), (0, 0, 255), 2)
# cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 0, 255), cv2.FILLED)
# cv2.putText(img, "No Match", (x1 + 6, y2 - 6),
cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)

cv2.imshow('webcam', img)
if cv2.waitKey(1) == ord('q') or datetime.now() >= time_end:
break

# Release the camera and close all windows


cap.release()
cv2.destroyAllWindows()
return "Face detection and attendance monitoring system stopped."

@app.route('/clear', methods=['POST'])
def clear():
with open('endtime.csv', 'w') as f:
f.truncate()
with open('Attendance.csv', 'w') as f:
f.truncate()
cap.release()
cv2.destroyAllWindows()
return " data cleared"

@app.route('/send', methods=['POST'])
def send():
recipientEmail = "[email protected]"
recipientEmail = recipientEmail.lower()

# Create a multipart message object


msg = MIMEMultipart()

# Add sender, recipient, and subject to the message object


msg['From'] = "[email protected]"
msg['To'] = recipientEmail
msg['Subject'] = "Attendance and End Time Report"

# Attach attendance.csv file to the message object


with open('attendance.csv', 'rb') as f:
att = MIMEApplication(f.read(),_subtype='csv')
att.add_header('Content-
Disposition','attachment',filename='attendance.csv')
msg.attach(att)

# Attach endtime.csv file to the message object


with open('endtime.csv', 'rb') as f:
att = MIMEApplication(f.read(),_subtype='csv')
att.add_header('Content-Disposition','attachment',filename='endtime.csv')
msg.attach(att)

try:
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login("[email protected]", 'bauzzkhmpwjxpjwi')
server.sendmail(msg['From'], msg['To'], msg.as_string())
print("sent to {}".format(recipientEmail))
server.close()
except Exception as e:
print(e)

return "Mail Sent Successfully"

if _name_ == "_main_":
app.run(debug=True)
CHAPTER – 9
RESULTS & DISCUSSIONS
CHAPTER – 10
CONCLUSION & FUTURE SCOPE

10.1 CONCLUSION:

The real-time face detection attendance system developed using opencv,


python, and other modules has several advantages, such as automation of
attendance management, accuracy of attendance records, and reduction of manual
labour.

The project's modules, including face recognition, attendance tracking,


user interface, data storage, image pre-processing, configuration, and security,
were designed and implemented to achieve these advantages.

Furthermore, the system's non-functional requirements, such as usability,


reliability, security, and performance, were carefully considered and tested using
a test case matrix.

Overall, the real-time face detection attendance system is a powerful tool


for attendance management that can be easily customized to meet the unique
needs of different institutions or organizations.

10.2 FUTURE SCOPE:

There are several possible future developments and enhancements that


could be made to the real-time face detection attendance system:

Integration with other biometric technologies: The system can be


extended to include other biometric technologies, such as fingerprint recognition,
to increase accuracy and security.
Real-time notification system: A real-time notification system could be
implemented to alert administrators when students arrive or leave the premises,
allowing for better monitoring and control.

Cloud-based data storage: The system's data storage module can be


extended to include cloud-based storage, allowing for easier access to attendance
records from anywhere with an internet connection.

Machine learning-based face recognition: By incorporating machine


learning algorithms, the system can improve its accuracy in recognizing faces and
reduce false positives and negatives.

Multi-language support: The user interface can be extended to support


multiple languages, allowing institutions in different countries to use the system
easily.

Integration with existing student information systems: The system can


be integrated with existing student information systems, allowing for easier
management of student data and better coordination between different
departments within an institution.

Overall, these future developments and enhancements would improve the


system's functionality, usability, and security, making it an even more valuable
tool for attendance management in various institutions and organizations.
REFERENCE

[1] Asri Nuhi, Agon Memeti, Florinda Imeri, Betim Cico, “Smart Attendance
System using QR code”, 9th Mediterranean conference Embedded
Computing, Budva, Montenegro, 2020

[2] M.A. Meor, M.H. Misran, M.A. Othman, M.M. Ismail, H.A. Sulaiman, A.
Salleh, N. Yusop Centre for Telecommunication Research and Innovation
FakultiKej. ElektronikdanKej. Komputer Universiti Teknikal Malaysia
Melaka Hang Tuah Jaya, Durian Tunggal 76100, Melaka, Malaysia ,2014

[3] Amena Khatun, A.K.M Fazlul Haque, Sabbir Ahemad, Mohammad


Rahman, “Design and Implementation of Iris Recognition Based
Attendance Management System”. ICEEICT Jahangirnagar University,
Bangladesh, 2015.

[4] Shreyak Sawhney, Karan Kacker, Samyak Jain, Shailendra Narayan Singh,
Rakesh Garg, “Real-Time Smart Attendance System using Face
Recognition Techniques” in Amity University Uttar Pradesh, Noida, 2019.

[5] Awais Ahmed, “LBPH based Improved face recognition at low


Resolution” UNIVERSITY OF ELECTRONIC SCIENCE AND
TECHNOLOGY OF CHINA 2018 IEEE

[6] “Multi-Faces Recognition Process Using Haar Cascades and Eigenface


Methods” Teddy Mantoro, Media A. Ayu, Suhendi Sampoerna University,
Jakarta, Indonesia, 2018
[7] HAO YANG AND XIAOFENG HAN “Face Recognition Attendance
System Based on Real-Time Video Processing” is supported in part by the
Basic Public Welfare Research Project of Zhejiang Province under Grant
LGF20H180001, 2020

[8] A brief history of Facial Recognition, NEC, New Zealand,26 May


2020.[Online]. Available: https://www.nec.co.nz/market-
leadership/publications-media/a-brief-history-of-facialrecognition/

[9] Paul Viola and Michael Jones, Rapid Object Detection using a Boosted
Cascade of Simple Features. Accepted Conference on Computer Vision
and Pattern Re cognition, 2001.

[10] Asri Nuhi, Agon Memeti, Florinda Imeri, Betim Cico, “Smart Attendance
System using QR code”, 9th Mediterranean conference Embedded Computing,
Budva, Montenegro, 2020

[11] M.A. Meor, M.H. Misran, M.A. Othman, M.M. Ismail, H.A.
Sulaiman, A. Salleh, N. Yusop Centre for Telecommunication Research
and Innovation FakultiKej. ElektronikdanKej. Komputer Universiti
Teknikal Malaysia Melaka Hang Tuah Jaya, Durian Tunggal 76100,
Melaka, Malaysia ,2014

[12] Amena Khatun, A.K.M Fazlul Haque, Sabbir Ahemad, Mohammad


Rahman, “Design and Implementation of Iris Recognition Based
Attendance Management System”. ICEEICT Jahangirnagar University,
Bangladesh, 2015.
CONFERENCE CERTIFICATE
REAL TIME FACE DETECTION ATTENDANCE
MONITORING
TEAM GUIDE: MRS.SHOBA.L.K,
ASSISTANT PROFESSOR, DEPARTMENT OF IT, JEPPIAAR
ENGINEERING COLLEGE.
STUDENT NAME: M. HARESH, M. ABIJITHNIKASH, V. NANDHA
KUMAR
UG STUDENTS, DEPARTMENT OF INFORMATION TECHNOLOGY.
EMAIL: [email protected], [email protected] ,
[email protected].
--------------------------------------------------------***--------------------------------------------------------------

ABSTRACT:

▪ The management of the attendance can be a great burden on the teachers if it is


done by hand. To resolve this problem, smart and auto attendance management
system is being utilized. By utilizing this framework, the problem of proxies and
students being marked present even though they are not physically present can
easily be solved. The frames are extracted from video using OpenCV. The main
implementation steps used in this type of system are face detection and
recognizing the detected face, for which dlib is used. After these, the connection
of recognized faces ought to be conceivable by comparing with the database
containing student's faces. This model will be a successful technique to manage
the attendance of students.

▪ Live Webcam based Face Attendance System Project through python


programming.

▪ Smart Attendance Management System is an application developed for daily


student attendance in colleges or schools.

You might also like