Skip to content

alperrkilic/Face-Recognition---Realtime-Database--Improved-Version-

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Face Recognition with Realtime Database

A Face Recognition Project
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Images
  4. License
  5. Contact
  6. Acknowledgments

About The Project

Product Name Screen Shot

Welcome to our Face Recognition with Realtime Database project, which aims to provide a seamless attendance-taking experience for educational institutions. With this system, we have created an efficient and reliable method for tracking students' attendance in real-time, using facial recognition technology and a Firebase database.

The system stores data and images of each student in the Firebase database, including their name, ID, major, starting year, last attendance, and total attendance. Each student is categorized according to their unique ID number and is treated as an object in the system. Their images are also stored in the database alongside their ID number.

Using facial recognition, the system matches the image captured by the camera with the images stored in the database. Once a match is found, the corresponding student's information is downloaded from the database and displayed on the user interface.

To prevent duplicate attendance, the system has several modes, including active, marked, already marked, no match, and display mode. When a student is detected, their ID is stored and their information is downloaded from the database. The UI mode is then set to "marked" for a few seconds to indicate that the student has been successfully marked as present. If the same student attempts to check in again, the system will switch to the "already marked" mode to prevent duplicate attendance.

When a student is marked as present, their last attendance and total attendance records are updated in the database. With the elapsed time, the system can control when a student can be marked present again, ensuring accurate attendance records.

Overall, our Face Recognition with Realtime Database project offers a reliable, convenient, and efficient way to take attendance in classrooms. With this system, educational institutions can implement automatic attendance-taking, saving time and improving accuracy.

(back to top)

Built With

Our Face Recognition with Realtime Database project is built with Python, OpenCV, dlib, numpy, and face_recognition libraries. These powerful tools allow us to detect and recognize faces from live video feeds and automatically take attendance. With our system, you can save time and streamline attendance-taking in classrooms and events.

  • Python
  • openCV

(back to top)

Getting Started

Before you can get started with our Face Recognition with Realtime Database project, you need to make sure that you have a few prerequisites in place. Don't worry; these are straightforward to set up, and we'll guide you through the process.

To use our system, you will need to have Python 3.x installed on your computer, along with pip (the Python package manager). You'll also need to create a Firebase account and project, and obtain the necessary credentials to access the Firebase database. Additionally, you'll need a webcam or camera to capture the students' faces for attendance purposes.

Once you have all the prerequisites in place, you can easily install and set up the Face Recognition with Realtime Database project by following a few simple steps. We've provided detailed instructions in the "Installation" section of this README file to help you get started quickly.

Prerequisites

To install the required files, please enter the following commands into your terminal:

  • pip

    pip install opencv-python 
    pip install cvzone
    pip install numpy
    pip install cmake
    pip install dlib
    pip install face-recognition
    pip install firebase_admin
    pip install pickle

    If you're having trouble installing dlib for our Face Recognition with Realtime Database project, there are a few things to keep in mind. First, note that dlib and face_recognition packages only work with Python 3.7, 3.8, and 3.9. So make sure you're using one of these Python versions

    If you're on Windows 11 and having trouble installing dlib, you can refer to this helpful guide by Sacha De'Angeli: https://github.com/sachadee/Dlib. It provides detailed steps to help you install dlib successfully on Windows 11.

    We hope this note helps you resolve any issues you may encounter during the installation process. If you still have questions or need further assistance, please feel free to reach out to us for support.

Installation

Installing the Face Recognition with Realtime Database project is quick and easy. Follow these simple steps to get started in just a few minutes!

  1. Create your virtual environment with Pycharm

  2. Clone the repository to your local machine:

    git clone https://github.com/alperrkilic/Face-Recognition---Realtime-Database--Improved-Version-
  3. Install the required dependencies:

    Visual Studio 2019 || Visual Studio 2022

    Note: This project is built with Python 3.8, so make sure you have it installed on your machine.

  4. Open the project in Visual Studio Code or your preferred code editor.

    That's it! You're now ready to use the Face Recognition with Realtime Database Project.

(back to top)

Images

Screen Shots

This is active mode when there's no face detected through webcam

Screen Shots

To account for the time it takes to compare faces, the system displays a loading message until a match is found. Once a match is detected, the corresponding student data is displayed.

Screen Shots

If a match is found between the detected face and the faces in our database, the system displays the corresponding user data retrieved from the Firebase server.

Screen Shots

If the face has been matched before, the system will display Already Marked mode.

Screen Shots

If there's no match between the face and the student images, system will display No Match mode.

How it works ?


EncodeGenerator.py

Screen Shots

The 'findEncodings()' function in the 'EncodeGenerator.py' file accepts an 'imagesList' parameter and encodes the images, storing them into the 'encodeList' array. To read this data from the 'main.py' file, we need to write the encodings to a file.


Screen Shots

This step involves generating the 'EncodeFile.p' that 'main.py' will use.


Screen Shots

To work with a database, we need to upload our images to it. The 'fileName' variable stores the path of the image, which is then uploaded to the database using the 'upload_from_filename()' function with 'fileName' as the parameter.

See the EncodeGenerator.py for the detailed explanations on the code.


AddingDataToDatabase.py

Screen Shots

This step involves accessing to the database with the 'serviceAccountKey.json' file and the URL for the project.


Screen Shots

Every student's data is stored in a variable called 'data', which holds the students as objects according to their ID numbers. Here is an example of a student.


Screen Shots

Finally, to update the data in our Firebase database, we need to set the new values, which are the student objects.

See the AddingDataToDatabase.py for the detailed explanations on the code.

main.py

Screen Shots

In our 'main.py' file, we will use the 'EncodeFile.p' that we generated with 'EncodeGenerator.py'. To do this, we open the file in read mode and store the values inside 'encodeListKnownWithIds'. Next, we store the encodings and IDs into separate variables so that we can use them later.


Screen Shots

Within this loop, the variable encodeCurFrame stores the encoded image of the webcam for each frame, while faceCurFrame stores the location of the face in the current frame. The purpose of this loop is to compare the encodings between the current frame and those previously generated by EncodeGenerator.py. If there is a match, the modes of the user interface can be switched accordingly within our system.


Screen Shots

The 'matches' array holds boolean values that indicate whether the face on the webcam matches a face in our database. If the faces match, then the corresponding element in the array is set to true. The 'faceDis' array holds the distances between faces. A lower distance indicates that the faces are more similar.

See the main.py for the detailed explanations on the code.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Bayram Alper KILIÇ - @alperrkilic - alperkilicbusiness@gmail.com

Project Link: https://github.com/alperrkilic/Face-Recognition---Realtime-Database--Improved-Version-

(back to top)

Acknowledgments

Creating a project like the Face Recognition with Realtime Database requires a lot of research, experimentation, and dedication. I would like to take this opportunity to acknowledge and thank the many individuals, channels, and websites that helped me along the way. Without their guidance and support, this project would not have been possible. In particular, I would like to recommend the following channels and websites for their invaluable resources and contributions to the field of computer vision and image processing.

(back to top)

About

A Face Attendance Project with Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages