This project is a face attendance system that uses facial recognition to identify individuals and update their attendance records. It integrates with Firebase for database and storage management and utilizes OpenCV and face_recognition libraries for face detection and recognition.
- Real-time Face Detection and Recognition: Uses the camera feed to detect and recognize faces in real-time.
- Attendance Tracking: Updates attendance records based on recognized faces and stores them in a Firebase Realtime Database.
- Image Retrieval: Fetches student images from Firebase Storage for display.
- UI Display: Provides a graphical user interface with real-time feedback on attendance status and student information.
Ensure you have the following software installed:
- Python 3.x
- OpenCV (
opencv-python
) - NumPy (
numpy
) - Face Recognition (
face_recognition
) - Firebase Admin SDK (
firebase-admin
) - Python-dotenv (
python-dotenv
) - cvzone (
cvzone
)
-
Clone the Repository
git clone https://github.com/KaivanKeren/face-attendance.git cd face-attendance
-
Install Dependencies
Create a virtual environment and install the required packages:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install -r requirements.txt
-
Setup Firebase
- Create a Firebase project and obtain the necessary credentials.
- Download the Firebase Admin SDK private key and save it as
firebase_credentials.json
. - Set up your Firebase Realtime Database and Firebase Storage.
-
Environment Variables
Create a
.env
file in the project root directory and add the following environment variables:FIREBASE_CREDENTIALS_PATH=path/to/firebase_credentials.json DATABASE_URL=https://your-database-url.firebaseio.com/ STORAGE_BUCKET=your-storage-bucket-name
-
Prepare Resources
- Place the background image and mode images in the
Resources
folder. - Ensure the encoding file (
EncodeFile.p
) is present in the project root.
- Place the background image and mode images in the
-
Run the Script
Execute the main script to start the attendance system:
python main.py
-
Operation
- The application will display the camera feed with real-time face detection.
- Recognized faces will update the attendance records and show student information on the screen.
- Press
q
to quit the application.
- Imports and Setup: Loads environment variables, initializes Firebase, and sets up video capture.
- Resource Loading: Loads images and encoding files.
- Main Loop: Captures frames from the camera, detects faces, recognizes them, and updates the attendance records.
- Firebase Integration: Fetches and updates student data in Firebase Realtime Database and retrieves images from Firebase Storage.
- UI Update: Updates the display with student information and attendance status.
- Ensure that all paths in the
.env
file and code are correctly set. - Check that the camera is properly connected and accessible.
- Verify that Firebase credentials and database URLs are correct.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to fork the repository and submit pull requests for improvements or bug fixes. For major changes, please open an issue to discuss the modifications.
For any questions or feedback, you can reach out to me at x.iml.7122@gmail.com.