A real-time attendance system built with Python, OpenCV, and Firebase Realtime Database, that marks student attendance automatically using facial recognition.
- Python 3
- OpenCV β For real-time webcam input and image handling
- face_recognition β For detecting and recognizing student faces
- Firebase Admin SDK β For syncing with Firebase Realtime Database and Storage
- cvzone β For drawing UI elements on the screen
- NumPy β For image and data array processing
- π― High Accuracy: Prevents proxy attendance and manual marking errors.
- β‘ Fast & Automatic: Detects and marks attendance instantly using a webcam.
- ποΈ Live Feedback: Students get immediate visual confirmation of their attendance.
- π Smart Data Handling: Attendance is safely stored in Firebase and easy to manage.
- π Flexible Use: Works seamlessly in schools, colleges, or office setups.
FaceRecognitionAttendance/
βββ Images/ # Student face images (named by ID)
βββ Resources/
β βββ background.png # App UI background layout
β βββ Modes/ # UI screens (Loading, Marked, Already Marked, etc.)
βββ EncodeGenrartor.py # Generates encodings and uploads them to Firebase
βββ main.py # Main app script for face recognition and attendance
βββ EncodeFile.p # Serialized (pickled) face encodings
βββ serviceAccountKey.json # Firebase credentials (keep private)
- π€ Real-time face recognition using webcam for automatic attendance
- π‘ Instant Firebase Realtime Database integration for storing attendance records
- πΌοΈ Graphical UI with visual feedback: "Active", "Marked", "Already Marked", "Loading"
- π Displays student details: Name, ID, Branch, Year, Major, etc.
- π§ Uses pickle-based facial encoding for fast and efficient recognition
- π Prevents duplicate entries with "Already Marked" alert
- π Secure and scalable using Firebase Admin SDK credentials
Below are the screenshots of the graphical user interface of the Face Recognition Attendance System:
System is ready for face recognition.
Displays student details like Name, ID, Branch, Year, Major.
Attendance has been recorded for the student.
The student has already been marked as present.
To set up the Face Recognition Attendance System on your local machine, follow these steps:
Start by cloning the repository to your local machine:
git clone https://github.com/harshitnagar22/face-attendance-system-python-opencv.git
cd face-attendance-system-python-opencv
Once the virtual environment is activated, install the required Python packages using the following command:
pip install -r requirements.txt
Download your Firebase Admin SDK credentials (serviceAccountKey.json
) from your Firebase project and place it in the root directory of the project.
You're now ready to run the Face Recognition Attendance System:
python main.py
- Add student face images inside the
Images/
folder (e.g., 1001.png, 1002.png). - Generate encodings and upload data: python EncodeGenrartor.py
- Start the face recognition system: python main.py
To use an external webcam, change this line in main.py
:
cap = cv2.VideoCapture(1) # Use 1 or 2 based on your camera index
Harshit Nagar
π BTech CSE @ JECRC University
π LinkedIn: https://www.linkedin.com/in/harshit-nagar-708a27290
Contributions are welcome! If you have ideas to improve this project, feel free to fork the repo and submit a pull request.
- π΄ Fork the repository
- π οΈ Create your feature branch (
git checkout -b feature/YourFeature
) - β
Commit your changes (
git commit -m 'Add some feature'
) - π Push to the branch (
git push origin feature/YourFeature
) - π¬ Open a Pull Request
- Fixing bugs π
- Improving performance βοΈ
- Enhancing UI π¨
- Adding new features π‘
- Improving documentation π
Make sure your code follows clean coding practices and includes comments where necessary.
The Face Recognition Attendance System is ideal for various settings:
- Automates student attendance and prevents proxy attendance.
- Tracks employee attendance and integrates with HR systems.
- Quick and accurate attendance verification for event participants.
- Verifies real-time attendance in virtual classrooms.
The project is evolving with exciting future enhancements:
- Integrate with LMS for automatic course attendance and HR systems for employee tracking.
- Real-time attendance alerts and detailed reports with visual data.
- A mobile app for easy attendance tracking on the go.
- Add facial expression recognition to track engagement.
- Optimize for large-scale use in universities and big organizations.
If you found this helpful, star the repo π and share it with others!
This project is licensed under the MIT License.
See the LICENSE file for details.