Real Time Face Detection Report
Real Time Face Detection Report
MONITORING
A PROJECT REPORT
Submitted by,
ABIJITHNIKASH.M (310819205004)
HARESH.M (310819205035)
NANDHA KUMAR.V (310819205048)
of
BACHELOR OF TECHNOLOGY
in
INFORMATION TECHNOLOGY
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.
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
ii
TABLE OF CONTENT
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
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
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
REFERENCE
CONFERENCE CERTIFICATE
CONFERENCE PAPER
iv
LIST OF FIGURES
LIST OF ABBREVIATION
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:
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.
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.
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:
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.
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 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.
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.
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.
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.
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.
4.1 INTRODUCTION:
PYTHON:
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.
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.
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.
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.
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.
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
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.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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
• 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.
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.
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.
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.
• 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
• 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_
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()
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
@app.route('/stop', methods=['POST'])
def stop():
global cap
cap.release()
cv2.destroyAllWindows()
cv2.imshow('webcam', img)
if cv2.waitKey(1) == ord('q') or datetime.now() >= time_end:
break
@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()
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)
if _name_ == "_main_":
app.run(debug=True)
CHAPTER – 9
RESULTS & DISCUSSIONS
CHAPTER – 10
CONCLUSION & FUTURE SCOPE
10.1 CONCLUSION:
[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
[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.
[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
ABSTRACT: