Face Recognition Based Attendance System with GUI Using Opencv and Tkinter
By: Meet Suvariya
Tags: Python, Opencv, Tkinter, Face Recognition

Nowadays everyone wants that technology can help them to make them work easily. So as an IT student I made one simple project which can help to take attendance so easily without any paperwork.

Face Recognition

Purpose:

The basic purpose of this project is to take attendance using face detection. This program makes CSV file of present attendees automatically After successful face detection. Also, It will make a CSV file for registered student's info.

libraries:

I made this program using these libraries. OpenCV, Numpy, OS, Pandas, Tkinter.

Flow diagram:

Flow Diagram

I’m going to explain my whole project in 4 parts.

Part 1: GUI

In this project, I made one simple GUI using the python Tkinter library so that the user can easily use this project without any backend knowledge. Tkinter is the standard GUI library for Python.

For making this GUI I mainly used Tkinter’s frame, menubar, button, label, message box, table, textbox, etc. I divide my main screen into two parts which are nothing but frames. one is for Registration and the second is for taking attendance.

GUI

As shown in the above image this GUI will help users to register new students as well as to take attendance. At the bottom, it will also show you the total number of registered students.

This GUI window also contains menubar with two sub-menu Help and About. The help menu contains 3 commands contact me, change Admin Password, exit.

Change Admin Password

Part 2:Take Images

when users register for new students it will take 100 images of that student and save these images to one folder which will be created at the time of first registration. I use OpenCV to take images and detection.

OpenCV is a library of programming functions mainly aimed at real-time computer vision. I used a cascade classifier of OpenCV for face detection. To use this cascade classifier we need the haarcascade_frontalface_default.xml file which includes all the haar cascade features of a face.

Taking Images

When users want to register new students they have to enter first details like ID and Name. After that, they have to take images of the student for that when the user presses the button ‘Take Images’ webcam will start and it will take 100 images of the student.

There are some methods in OpenCV to take Images. using videoframe of OpenCV I’m taking frames and from that, I’m extracting only face images using cascade classifier. After taking images I will store those images in one folder.

100 Images Stored in particular Folder

Part 3: save Profile

When images will be taken for any student user needs to click the ‘save profile’ button so that it will ask for the admin password. If the admin password was not set it will ask you first to set the admin password or else you need to enter the admin password. This password will be saved in one plan txt file.

If this password is correct then it will call the trainer function which will be going to generate a YML file and it will train our LBPH recognizer using those 100 images. This YML file and password txt file will save in one different folder name “pass_train”.

After saving the profile there are 3 different folders generated in the current directory. Out of that 3 folders, one is containing images of students, the second one is containing a CSV file of student’s details and the third one is containing a pass.txt file and YMLfile.

After saving profile

Part 4:Taking attendance

When a user wants to take attendance and press the ‘take attendance’ button webcam will start and one videoframe window will generate to recognize the faces using the YML file. If the face will successfully recognize then it will put the name of the person at the bottom of the rectangle which is showing the detected face area.

Taking Attendance

After successfully recognized the attendance will be shown in the table in the 2nd frame and the Attandance.csv file will be generated in a particular folder. This CSV file contains the student’s ID, name along with time at which attendance was taken for that student.

Attendance Table

After taking attendance

Attendance will store in one CSV file. This CSV file will be created datewise i.e attendance of one day is store in one CSV file. If a person will not recognize then in a video capturing it will show unknown. Let’s look at the CSV file of attendance.

Attendance.CSV

This is the whole flow of the Attendance system based on face recognition. Here I attach a link to my Github repository.