0% found this document useful (0 votes)
4 views37 pages

Blind Assistance Cap for Visually Impaired

The project report details the development of a Blind Assistance Cap designed to aid visually impaired individuals by detecting obstacles using ultrasonic sensors and providing audio alerts. The system, powered by an Arduino Nano, is lightweight, cost-effective, and does not require internet connectivity, making it suitable for everyday use. This innovative wearable device enhances mobility and safety for users by allowing them to navigate their surroundings more independently.

Uploaded by

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

Blind Assistance Cap for Visually Impaired

The project report details the development of a Blind Assistance Cap designed to aid visually impaired individuals by detecting obstacles using ultrasonic sensors and providing audio alerts. The system, powered by an Arduino Nano, is lightweight, cost-effective, and does not require internet connectivity, making it suitable for everyday use. This innovative wearable device enhances mobility and safety for users by allowing them to navigate their surroundings more independently.

Uploaded by

notih75530
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

BLIND CAP ASSISTANCE DEVICE FOR BLIND PEOPLE

PROJECT REPORT

Submitted in partial fulfilment of the requirements


for the award of the Diploma in Computer Science
and Engineering at Government Polytechnic
College, Bundi.

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING

GOVERNMENT POLYTECHNIC COLLEGE


BUNDI (Raj.)

Submitted By: Guide By:


1. Rishiraj Singh Mr. Sanjay Kumar
2. Nitesh Puri Meena (Lecturer, CSE
3. Nikhil Saini Department)
4. Saijiya Ansari
5. Fazil

1
June 2025

2
DECLARATION
We, Rishiraj Singh, Nitesh Puri, Nikhil Saini, Sajiya Ansari and Mohammed Inam
Fazil hereby declare that the Project Report entitled “Blind Cap Assistance Device for
Blind People,” completed by me under the guidance of Lecturer Sanjay Kumar Meena,
is submitted in partial fulfillment of the requirements for the award of the Diploma in
Computer Science and Engineering at Government Polytechnic College, Bundi.

DATE: 11 JUNE 2025 Name of Students


1. Rishiraj Singh
2. Nitesh Puri
3. Nikhil Saini
4. Sajiya Ansari
5. Mohammed Inam Fazil

3
ACKNOWLEDGEMENT

We are pleased to acknowledge my sincere thanks to the Board of Technical Education,


Rajasthan for their kind encouragement in undertaking this project and for providing the
opportunity to successfully complete it. I am truly grateful to them.
I extend my heartfelt thanks to Mr. P. K. Singh, Head of Department, and to Lecturer Mr.
Awadhesh Singh and Mr. Sanjay Kumar Meena for providing the necessary support and
guidance at the right time during the various stages of this project.
I would like to express my deep sense of gratitude to my Project Guide, Mr. Sanjay Kumar
Meena, for his valuable guidance, suggestions, and constant encouragement, which paved the
way for the successful completion of my project work.
I also wish to express my sincere thanks to all the Teaching and Non-Teaching staff members
of the Department of Computer Science and Engineering who extended their help and
support in various ways towards the completion of this project.

4
ABSTRACT
The primary objective of this project is to develop a Blind Assistance Cap using
ultrasonic sensing technology, powered by an Arduino Nano and programmed in the C
language using the Arduino IDE. The system is designed to aid visually impaired
individuals by detecting nearby obstacles and providing real-time directional alerts through
audio signals.

The wearable device integrates three ultrasonic sensors, strategically positioned on a cap to
cover the left, front, and right directions. These sensors continuously monitor the
surroundings and calculate the distance of objects in their respective paths. When an
obstacle is detected within a specified range, the Arduino Nano triggers a corresponding
buzzer to notify the user through sound. This directional audio feedback allows the user to
understand the obstacle’s position and avoid collisions.

The system is lightweight, cost-effective, and battery-powered, making it suitable for


everyday use without reliance on smartphones or internet connectivity. Programming logic
is implemented in the C language using the Arduino IDE, enabling precise control of
sensor readings and buzzer activation based on distance thresholds.

This project demonstrates a practical application of embedded systems and sensor-based


automation in the field of assistive technology. It highlights how basic programming,
microcontrollers, and commonly available electronic components can be combined to
create an affordable, wearable solution that significantly improves the mobility and safety
of visually impaired individuals.

5
TABLE OF CONTENT

Chapter Title Page No.


No.
1. Introduction 7-8

2 Literature survey 8–9


3. Aim and Scope of the Project 9 - 10
4. Methods and materials used 11 - 14
5. Results and discussion 15-16
6. Summary and conclusion 16-17
7. Appendix 16-25
8 References 30-30

LIST OF FIGURES

Figure Title Page No.


No.
1 Project architecture 9
2 Registration page 11
3 Student table 11
4 Model training 12
5 Attendance page 12
6 Student attendance database 13
7 Save in excel file 13
8 List page 16
9 Item page 17
10 Checkout page 17
11 Output 28

6
CHAPTER 1
INTRODUCTION

In today's world, technology has become an essential tool for solving real-life challenges,
especially for people with disabilities. One such challenge faced by visually impaired individuals
is safe and independent navigation in unfamiliar environments. Without the ability to see, they
often rely on traditional aids like walking sticks or the help of others. However, these methods
have limitations and may not always detect obstacles at head level or from the sides.

To solve this problem, we have developed a project called the Blind Assistance Cap. This smart
wearable device is designed to help visually impaired individuals detect nearby obstacles using
sensors and receive audio feedback through buzzers. The system is built using an Arduino Nano
microcontroller, three ultrasonic sensors, and buzzers to provide real-time obstacle alerts.

The programming for this project is done in C language using the Arduino IDE. The ultrasonic
sensors measure the distance of objects in front, to the left, and to the right. When any object is
detected within a certain range (e.g., 40 cm), the buzzer corresponding to that direction is
activated, helping the user to sense which side the obstacle is on and avoid it.

The working of the system is simple:

 The ultrasonic sensors continuously monitor the surroundings.


 The Arduino Nano processes the sensor data.
 If an obstacle is detected, a buzzer placed near the ear alerts the user with a sound from
that specific direction.

This cap is lightweight, low-cost, and easy to use. It does not require an internet connection,
smartphone, or any external devices. The idea is to create a practical, wearable, and affordable
assistive device for those who are blind or have low vision.

There are many advantages to using this project: it gives users greater independence, prevents
accidental collisions, and improves safety and mobility. The cap is especially useful in crowded
or unfamiliar areas where obstacle detection is critical. By combining basic electronics and
embedded programming, our project demonstrates how simple innovations can make a big
difference in real life.

7
CHAPTER 2
LITERATURE SURVEY

Attendance management is an essential task in every educational institution for maintaining


discipline and academic records. Traditional methods like class registers and biometric systems
are time-consuming and prone to errors and manipulation. Even though biometric systems such as
fingerprint or RFID cards are better than manual methods, they are contact-based and can be
misused by proxy attendance, where one student marks attendance for another. Especially during
the COVID-19 pandemic, contact-based systems posed hygiene concerns, highlighting the need
for a safer, contactless solution.

In the digital era, artificial intelligence tools have transformed many traditional processes. One
such advancement is the use of facial recognition technology for attendance systems. Face
recognition provides a secure, efficient, and contactless alternative, reducing the risk of proxy
attendance and saving valuable time.

Based on this, our project introduces a Face Attendance System that uses the system’s camera to
capture attendance through facial recognition. We developed this application using technologies
like Python, OpenCV for face detection, MySQL for database management, and PyQt for
designing a user-friendly graphical interface. The system uses the LBPH (Local Binary Pattern
Histogram) Face Recognizer for recognizing faces from a live camera feed, while Haarcascade
classifiers help detect faces within images.

In our system, students are first registered by filling in basic details and capturing images. These
images, stored in a dedicated folder linked to a unique student ID, are used to train a machine
learning model. Attendance is then marked by recognizing faces in real-time, and records are
saved in both the database and Excel files. Our survey concludes that face recognition-based
systems are faster, contactless, accurate, and effectively reduce proxy attendance compared to
traditional methods.

8
CHAPTER 3
AIM AND SCOPE OF THE PROJECT

3.1 PURPOSE OF THE PROJECT


The goal of this project is to develop a contactless Face Attendance System for educational
institutions. Traditional attendance methods like registers, biometric scanners, and RFID
cards are time-consuming, prone to errors, and raise hygiene concerns, especially during
health crises like COVID-19.
Pre-requisites:
 Basic knowledge of Python programming
 Understanding of OpenCV and MySQL
 Familiarity with GUI development With PyQt
Technologies:
 Python
 OpenCV
 MySQL
 PyQt
 LBPH Face Recognizer
 Haarcascade files
Project overview:
This system uses live camera feeds to recognize students’ faces and automatically mark
attendance, ensuring only registered and present students are recorded. It eliminates proxy
attendance and human errors, saves class time, improves data management, and enhances
institutional discipline through digital automation.

9
3.2 PROJECT ARCHITECTURE

Image 1 - Project Architecture

I. User Interface (Frontend)


 Built with: PyQt (Python GUI Library)
 Functionality:
o Register new students with face data
o Start live attendance capture
o View attendance records in home page
o View captured images and training

II. Face Detection & Recognition Module


 Built with: OpenCV, LBPH Face Recognizer (Local Binary Patterns Histogram) and
 Functionality:
o Detect faces from live webcam feed
o Compare with registered faces in the dataset
o Recognize and identify the student
o Mark attendance if matched

III. Database (Backend)


 Database: MySQL
 Functionality:
o Store student records (Name, ID, Image path, etc.)
o Store attendance logs (Date, Time, Student ID)
o Also store in excel files

IV. Attendance Management System


 Functionality:
o Capture date & time for each attendance entry
o Prevent multiple attendance entries in a single session
o Allow admin to view, update, or export attendance record

10
CHAPTER 4
METHODS AND MATERIALS USED

5.1 METHOD USED

Face Detection:
Face detection was carried out using OpenCV's Haar Cascade Classifier, which detects
human faces from live webcam video streams by identifying patterns and features in
real-time.
Face Recognition:
The system uses the Local Binary Patterns Histogram (LBPH) Face Recognizer model,
which converts facial images into local binary patterns and compares them with the
stored data to identify and authenticate registered students.
Attendance Marking:
Upon successful face recognition, the system automatically marks attendance by storing
the student’s name, ID, date, and time in the database. The system also prevents
duplicate attendance within a single session.
Database Management:
A MySQL database is used for managing student records and attendance logs. It ensures
organized data storage, retrieval, and management.
User Interface Development:
The graphical user interface was developed using PyQt5 to provide a user-friendly
platform for student registration, live attendance capturing, and administrative
controls. For this purpose, we also use Qt Designer software, which is provided by
PyQt.

5.2 MATERIALS AND TOOLS USED

S. No Tool / Material Purpose


Python Primary programming language for
system development
OpenCV (Open-Source Face detection and recognition
Computer Vision
Library)
LBPH Face Recognizer Algorithm for accurate and reliable face
recognition
Qtdesigner software Development of graphical user interface
(GUI)
MySQL Database management and attendance
record storage
Visual Studio Code Code editor for software development

Webcam Capturing live video feed for face


(Integrated/External) recognition

11
5.3 WORKING EXPLANATION
 Registration Page:
This page is designed for registering new students into the system. The user is
required to enter essential student details such as Student ID, Name, Date of Birth,
Email, and other necessary information. After filling in the details, images of the
student can be captured directly via webcam by clicking the Capture button, which
saves multiple face images for training purposes.

Image 2 - Registration Page

 Student Table:
Once the images are captured, the user can click the Submit button to store the
student’s data into the Student Table. This data is saved using SQL queries with a
unique Student ID that helps in identifying students during the face recognition
process.

Image 3 - Student Table

12
 Train Model:
After registering students, the system requires training for face recognition. The
captured images are used to train the model using the Local Binary Patterns
Histogram (LBPH) Face Recognizer algorithm. This step enables the system to
recognize and match student faces accurately during attendance marking.

Image 4 - Model Training

 Attendance Page:
In the Attendance Window, the system captures live images through the webcam
and identifies students by matching their facial attributes with the images stored
in the database. If a match is found, the corresponding student’s attendance is
marked for that session.

Image 5 - Attendance Page


13
 Student Attendance Database:
When a student’s face is recognized, their details are fetched from the Student
Table using their Student ID, and the attendance information is stored in the
Student_Attendance database using SQL queries. Additionally, the attendance
record is also automatically saved in an Excel file for easy reporting and backup.

Image 6 - Student Attendance Database

Image 7 - Save in excel fill

14
CHAPTER 5
RESULTS AND DISCUSSION

5.1 Results

After successfully developing and testing the project, the system delivered very promising
results. The Face Attendance System was able to detect and recognize registered students’
faces in real-time using the webcam. As soon as a student stood in front of the camera, the
system would identify the face and automatically mark the attendance by saving the
student’s name, ID, date, and time into the database.
During testing, the system achieved an average accuracy of 90-95%, which is quite reliable
for a classroom environment. One of the best features of this system is that it prevents
duplicate attendance in the same session. Once a student’s attendance is marked, it cannot
be recorded again until the next session, ensuring error-free records.
The attendance records were securely stored in the MySQL database, and at the same time,
an Excel file was generated for maintaining offline reports. The Graphical User Interface
(GUI) created using PyQt5 was clean and easy to use. It provided smooth navigation for
student registration, capturing attendance, and handling admin controls.

5.2 Discussion

While working on this project, I realized how artificial intelligence and machine learning
can be applied practically to solve daily problems in educational institutions. By using facial
recognition technology, this system successfully tackled issues like proxy attendance,
manual errors, and time wastage during attendance marking.
For face recognition, I chose the Local Binary Patterns Histogram (LBPH) recognizer
because it works efficiently even with small datasets and is easy to implement. The model
performed well in various conditions, though in cases like poor lighting, background
changes, or face masks, the accuracy slightly dropped — which can be improved in the
future.
This system not only simplified attendance management but also ensured data security and
easy reporting. Features like automatic Excel export and duplicate prevention made it more
reliable for daily classroom use.
However, there’s always room for improvement. In the future, this system can be enhanced
by adding features like:
 Face mask detection.
 Remote attendance marking for online classes.
 SMS or email notifications for absent students.
 Further improving the recognition accuracy under challenging conditions.
 Attendance can be taken based on the class timetable
Overall, this project helped me gain hands-on experience in implementing AI-based
solutions and proved how technology can bring positive changes in academic management
systems. It was a great learning experience and a practical example of how simple ideas can
turn into smart digital solutions.

15
CHAPTER 6
SUMMARY AND CONCLUSION

SUMMARY
This project aimed to develop a smart, efficient, and contactless Face Attendance System for
educational institutions. Traditional attendance systems often face issues like proxy
attendance, manual errors, and time consumption. To overcome these challenges, this system
uses facial recognition technology to automate the attendance process in a secure and reliable
manner.
The system was designed using Python, OpenCV, PyQt5, MySQL, and the LBPH Face
Recognizer model. It includes different modules such as student registration, model training,
attendance capturing, and database management. Real-time face detection and recognition
was successfully implemented through a webcam, and attendance data was securely stored in
a MySQL database and also exported to Excel files for easy reporting.
During testing, the system showed high accuracy and efficiency, achieving 90-95% face
recognition accuracy in controlled classroom conditions. The project also demonstrated the
practical use of artificial intelligence and machine learning in solving real-world problems.

CONCLUSION
In conclusion, the Face Attendance System successfully provides a modern and reliable
solution for attendance management in educational institutions. The system effectively
eliminates issues like proxy attendance and manual errors, while also saving valuable
classroom time.
By integrating AI-based face recognition with database management and user-friendly
interfaces, this project contributes to the digital transformation of academic processes.
Although the system performed well, certain limitations like varying lighting conditions and
face masks slightly affected accuracy, which opens scope for future enhancements.
Overall, this project was a valuable learning experience, offering hands-on exposure to
machine learning, Python programming, database handling, and GUI development. It reflects
how technology can be practically applied to improve everyday processes in education and
beyond.

16
APPENDIX

A: SOURCE CODE
A.1 [Link] (GUI OF MAIN HOME PAGE)
from PyQt5 import
QtWidgets,QtCore from MPH
import PageWindow
from DashBoard import
Dashboard from registration
import Registration_
from take_attendance import
T_attendace from settings import
Settings
from about_us import About
from Trained_images import
t_images from Home import
HomePage

class
Project([Link])
: def init (self):
super(Project,self). init ()
self.stacked_w=[Link]
() [Link](self.stacked_w)
[Link]={}
self.register_page(Dashboard(),'Dash')
self.register_page(Registration_(),'regi')
self.register_page(T_attendace(),'t_attendac
e') self.register_page(About(),'about')
self.register_page(Settings(),'settings')
self.register_page(t_images(),'t_images')
self.register_page(HomePage(),'home')

[Link]('home')
def register_page(self,page,name):

[Link][name]=page
self.stacked_w.addWidget(pa
ge) if
isinstance(page,PageWindow
):
page.go_to_signal.connect([Link]
to) @[Link](str)
def goto(self,name):
if name in [Link]:
self.stacked_w.setCurrentWidget([Link][n
ame])

17
A.2 take_attendance.py

from MPH import PageWindow


from PyQt5 import QtWidgets, uic, QtCore
import sys
import cv2
import numpy as np
import sqlite3 as sq
from PIL import
Image import
pandas as pd
from [Link] import QImage,
QPixmap import [Link]
from datetime import datetime

class
T_attendace(PageWindow):
def init (self):
super(T_attendace, self). init () [Link](r"D:\PyQt\
take_attendance.ui", self)

[Link] = None
[Link] = [Link]()
[Link](self.update_frame)

[Link] = [Link]()
[Link](r"D:\python projects\Face_detection\reco\
[Link]")

[Link] = [Link](r"d:\python projects\Face_detection\


haarcascade_frontalface_default.xml")

[Link] = self.dash_b
self.Register_new.mousePressEvent = self.goto_Regi
[Link] = self.goto_About
[Link] = self.goto_settings
[Link] = self.goto_t_images
self.Home_page.mousePressEvent=self.goto_home

self.camera_w = [Link]([Link], "cam_window")

[Link](self.start_manually)
self.stop_b.[Link](self.stop_capturing)
self.save_attendance.[Link](self.save_in_excel)
self.Reset_c.[Link](self.reset_capture)
self.Home_B.[Link](self.goto_home)
#
self.s_table=[Link](self.student_tab
le) def reset_capture(self):

[Link]=None
self.student_table.setRowCount(0)

def start_manually(self):

18
[Link] = [Link](0)
[Link](30)

19
def update_frame(self):
ret, img =
[Link]() if not
ret:
return

gray = [Link](img,
cv2.COLOR_BGR2GRAY) faces =
[Link](gray,1.3,9)

for (x, y, w, h) in faces:


[Link](img, (x, y), (x + w, y + h), (0, 255, 0), 2)
crop=gray[y:y + h, x:x + w]

id_, conf =
[Link](crop) # if
conf>8:
#

id_=0
print(id_
)
print(co
nf)
[Link] = self.get_profile(id_)

if [Link] is not None:


[Link](img, (x, y - 20), (x + w, y), (0, 255, 0), -1)
[Link](img, "Name: " + str([Link][1]), (x + 5, y - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

color = [Link](img,
cv2.COLOR_BGR2RGB) h, w, ch = [Link]
bytes_per_line = ch * w
qt_image = QImage([Link], w, h, bytes_per_line,
QImage.Format_RGB888)
self.camera_w.setPixmap([Link](qt_image))
if hasattr(self, 'profile') and [Link] is not
None:
[Link]=[Link]().strftime("%d-
%m-%Y")

self.dict_st = {'id': [Link][0], 'name': [Link][1], 'gender': [Link][2],


'dob': [Link][3], 'branch':
[Link][4],'class':[Link][5], 'semester':
[Link][6],'email':[Link][7],'date':[Link]}

self.student_table.setRowCount(3)
self.student_table.setItem(0,0,[Link](str(self.dict_st['id'])))
self.student_table.setItem(0,1,[Link](self.dict_st['name']))
self.student_table.setItem(0,2,[Link](self.dict_st['gender']))
self.student_table.setItem(0,3,[Link](self.dict_st['dob']))
self.student_table.setItem(0,4,[Link](self.dict_st['branch']))
self.student_table.setItem(0,5,[Link](self.dict_st['class']))
self.student_table.setItem(0,6,[Link](self.dict_st['semester']))
20
self.student_table.setItem(0,7,[Link](self.dict_st['email']))
self.student_table.setItem(0,8,[Link](str(self.dict_st['date'])))

21
def
stop_capturing(self
): if
[Link]()
:
[Link]()
if [Link] and [Link]():
[Link]()
self.camera_w.clear

() def

get_profile(self,id_):

conn=[Link](host="localhost",
user="root",password="admin123",database="gpc")

cmd="SELECT * FROM students WHERE id =


%s" cursor = [Link]()
[Link](cmd,(id_,))
profile =
[Link]()

[Link]()
return profile

def save_in_excel(self):

if hasattr(self, 'profile') and [Link] and


[Link][0] != "": if [Link]():
print("1")
df = [Link](self.dict_st, index=[1, 2, 3, 4])
dob_date = [Link](self.dict_st['dob'],
"%d/%m/%Y").date() date = [Link]().date()
print("2")
df.to_excel(r"C:\Users\lappy garage\Flask code\face_attendance\
instance\[Link]", index=False)
print("3")

conn =
[Link](
host="localhost",
user="root",
password="admin123",
database="gpc"
)
print("4")
cursor = [Link]()

insert_attendance = "INSERT INTO students_attendance (id, name, gender,


dob, branch, class_, semester, email, date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s,
%s)"
print(self.dict_st['id'], self.dict_st['name'], self.dict_st['gender'], dob_date,
self.dict_st['branch'], self.dict_st['class'], self.dict_st['semester'], self.dict_st['email'],
date)

22
[Link](insert_attendance, (
self.dict_st['id'], self.dict_st['name'],
self.dict_st['gender'], dob_date, self.dict_st['branch'],
self.dict_st['class'], self.dict_st['semester'],
self.dict_st['email'], date
))
[Link]() # Don't forget to commit
changes! print("6")

23
message_box = [Link]()
message_box.setIcon([Link])
message_box.setWindowTitle("Information")
message_box.setText("Attendance successfully Saved")
message_box.setStandardButtons([Link])
message_box.exec_()

else:
error_box = [Link]()
error_box.setIcon([Link])
error_box.setWindowTitle("Check Box Error")
error_box.setText("Please! check the CheckBox ")
error_box.setStandardButtons([Link].
Ok) error_box.exec_()

else:
error_box = [Link]()
error_box.setIcon([Link])
error_box.setWindowTitle("Capture Error")
error_box.setText("Please! Capture attendance first")
error_box.setStandardButtons([Link].O
k) error_box.exec_()

def dash_b(self, event):


self.go_to('Dash')

def goto_Regi(self, event):


self.go_to('regi')
def goto_home(self,event):
self.go_to('home')

def goto_About(self, event):


self.go_to('about')

def goto_settings(self,
event):
self.go_to('settings')

def goto_t_images(self,
event):
self.go_to('t_images')

24
A.3 [Link]
from MPH import PageWindow
from PyQt5 import
QtWidgets,uic
from [Link] import
QImage,QPixmap import sys
import numpy as
np import os
import sqlite3 as sq
import cv2
import [Link]
class
Registration_(PageWindow):
def init (self):
super(Registration_,self). init () [Link](r"D:\PyQt\
[Link]",self)
[Link]=self.dash_b

[Link]=self.goto_attendace
[Link]=self.goto_About
[Link]=self.goto_settings
[Link]=self.goto_t_images
self.Home_page.mousePressEvent=self.goto_home
self.Home_B.[Link](self.goto_home)

self.image_label = [Link]([Link],
"camera_feed") #branch selection
self.branch_s=[Link]([Link],"Branch
_s")

#class selection
self.class_s=[Link]([Link],"class_s")

#semester selection
self.semester_s=[Link]([Link],"semester_s")

self.s_gender=[Link]([Link],"s_gender")
self.camera_feed = [Link]([Link], "camera_feed")

self.capture_b.[Link](self.insert_update)

self.reset_b.[Link](self.reset_form)
def reset_form(self):
self.branch_s.setCurrentIndex(0)

self.class_s.setCurrentIndex(0)

self.semester_s.setCurrentIndex(0)

self.s_gender.setCurrentIndex(0)

self.student_id.clear()

self.student_name.clear()

self.email_id.clear()

25
def insert_update(self):
self.branch_s=self.branch_s.currentText()
self.class_s=self.class_s.currentText()
self.semester_s=self.semester_s.currentText()
[Link]=self.student_id.text()
[Link]=self.student_name.text()
[Link]=self.email_id.text()
self.s_gender=self.s_gender.currentText()
[Link]=self.Date_of_birth.text()
conn=[Link](host="localhost",
user="root",password="admin123",database="gpc")
cursor = [Link]()
cmd="SELECT * FROM students WHERE id = %s"
[Link](cmd, ([Link],))
print("Enter kr gya")
record =
[Link]() if
record:
print("Record exists, updating...")
update_query = "UPDATE students SET name=%s, gender=%s, dob=%s,
email=%s, branch=%s, class_=%s, semester=%s WHERE id=%s"
[Link](update_query, ([Link], self.s_gender, [Link],
[Link], self.branch_s, self.class_s, self.semester_s, [Link]))
else:
print("No record found, inserting...")
insert_query = "INSERT INTO students (id, name, email, gender, dob, branch,
class_, semester) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
[Link](insert_query, ([Link], [Link], [Link], self.s_gender,
[Link], self.branch_s, self.class_s, self.semester_s))
[Link]()
[Link]()
[Link]()
fd=[Link](r"C:\Users\lappy garage\Flask code\
face_attendance\haarcascade_frontalface_default.xml")
cam=[Link]
(0) samplenum=0
while True:
ret,img=[Link]()
img=[Link](img,(500,291))
gray=[Link](img,cv2.COLOR_BGR2GRAY)
faces=[Link](gray,scaleFactor=1.3,minNeigh
bors=3) # reg=Registraion()
for (x,y,w,h) in faces:
samplenum=samplenum+1 file=r"C:\
Users\lappy garage\Flask
code\face_attendance\Dataset\image."+str([Link])+"."+str(samplenum)
+".jpg" crop=gray[y:y+h,x:x+w]
gray1=[Link](crop,(150,150))
[Link](file,gray1)
[Link](img,(x,y),(x+w,y+h),
(0,255,0),2)
[Link](img,str(samplenum-
1),(50,50),cv2.FONT_HERSHEY_COMPLEX,1,(0,0,255),2)
color=[Link](img,cv2.COLOR_BGR2RGB)
H,W,ch=[Link]
bytes_per_line = ch
26
*W
qt_image = QImage([Link], W, H, bytes_per_line, QImage.Format_RGB888)

27
self.image_label.setPixmap([Link](qt_image))
[Link](1)
if samplenum>30:

error_box = [Link]()
error_box.setIcon([Link])
error_box.setWindowTitle("Information")
error_box.setText("Student successfully Registerd")
error_box.setStandardButtons([Link].
Ok) error_box.exec_()
self.camera_feed.clear()
break
[Link]()
[Link]
()
def dash_b(self,event):
self.go_to('Dash')

def
goto_attendace(self,event
): self.go_to('t_attendace')

def goto_About(self,event):
self.go_to('about')
def
goto_settings(self,event):
self.go_to('settings')
def
goto_t_images(self,event):
self.go_to('t_images')
def goto_home(self,event):
self.go_to('home')

28
A.4 trained_images.py
from MPH import PageWindow
from PyQt5 import
QtWidgets,uic import sys
import os
from PyQt5 import QtWidgets, uic,
QtCore,QtGui from [Link] import
QLabel, QGridLayout from [Link] import
QPixmap,QImage
import cv2
from PIL import
Image import
numpy as np
class
t_images(PageWindow):
def init (self):
super(t_images,self). init () [Link](r"D:\PyQt\
Trained_images.ui",self)
[Link]=self.dash_b
self.Register_new.mousePressEvent=self.goto_Regi
[Link]=self.goto_atten
dace [Link]=self.goto_About
[Link]=self.goto_settings
self.Home_page.mousePressEvent=self.goto_home
[Link] = [Link](QGridLayout,
"gridLayout")
[Link] = [Link]([Link],
"refreshButton") [Link] =
[Link]([Link], "homeButton") self.model_train
= [Link]([Link], "model_t")

# Connect button actions


[Link](self.load_images)
self.model_train.[Link](self.model_training)
[Link](self.goto_home)

# Initial load
self.load_images()

def
load_images(self)
: # Clear old
widgets
while [Link]():
item = [Link](0)
widget = [Link]()
if widget is not None:
[Link]()

# Path to image folder


image_folder = r"C:\Users\lappy garage\Flask code\face_attendance\Dataset"

if not [Link](image_folder):
[Link](image_folder)

images = [f for f in [Link](image_folder) if [Link]().endswith(('.png', '.jpg',


29
'.jpeg', '.bmp'))] row, col = 0, 0
for i, image_name in enumerate(images):
image_path = [Link](image_folder,
image_name) pixmap =
QPixmap(image_path).scaled(200, 200,
aspectRatioMode=[Link])

30
label = QLabel()
[Link](pixmap)
[Link]("border: 1px solid #ccc; padding: 5px;")

[Link](label, row, col)

col +=
1 if col
> 5:
col = 0
row += 1
def model_training(self):
rc=[Link]()
path=r"C:\Users\lappy garage\Flask code\face_attendance\Dataset"
images_path=[[Link](path,f) for f in [Link](path)]
faces=[]
ids=[]
for single_image_path in images_path:
faceImage=[Link](single_image_path).convert('L')

faceNp=[Link](faceImage,np.uint8)

id=int([Link](single_image_path)[-1].split(".")[1])

[Link](faceNp)
[Link](id)
[Link]("trainnig",faceNp)
[Link](20)

def model_train(faces,id):
print(type(id))
ids=[Link](id)
[Link](faces,ids)
[Link](r"D:\python projects\Face_detection\reco\[Link]")
[Link]()
model_train(faces,id
s) def
dash_b(self,event):
self.go_to('Dash')

def
goto_attendace(self,event
): self.go_to('t_attendace')
def goto_Regi(self,event):
self.go_to('regi')
def goto_About(self,event):
self.go_to('about')
def
goto_settings(self,event):
self.go_to('settings')
def goto_home(self,event):
self.go_to('home')

31
B: DATABASE SCREENSHOTS

C: TRAINING IMAGE DATASET

32
D: GUI FILES

E: OUTPUT

Image 8 - Home Page

33
Image 9 - Attendance Page

Image 10 - Registration Page

34
Image 11 - Model Training Page

35
REFRENCES

1. OpenCV Documentation
Available at: [Link]
2. Python Official Documentation
Available at:
[Link]
3. PyQt5 Documentation
Available at: [Link]
4. MySQL Official Documentation
Available at:
[Link]
5. LBPH Face Recognizer - OpenCV Tutorial
Available at: [Link]
6. Machine Learning for Beginners: A Practical Guide
Available at: [Link]

36
37

You might also like