Face Recognition Attendance System
An automated attendance tracking system that uses computer vision and machine learning to recognize faces in real-time and log attendance automatically. Built with Python, OpenCV, and the Face Recognition API, this project demonstrates practical application of AI in solving everyday problems.
Overview
Manual attendance systems are time-consuming and prone to errors. This Face Recognition Attendance System automates the entire process by:
- Detecting faces in real-time using a webcam
- Recognizing registered individuals with high accuracy
- Logging attendance automatically with timestamps
- Providing a web interface for face registration and attendance management
The system is deployed at attendance-system-blue.vercel.app for easy access.
Key Features
1. Real-Time Face Detection
Uses Haar Cascade classifiers for fast and accurate face detection from webcam streams. The cascade approach provides:
- Low computational overhead
- Reliable detection even in varying lighting conditions
- Fast processing suitable for real-time applications
2. Face Recognition with Face Recognition API
Implements the face_recognition library built on top of dlib’s state-of-the-art face recognition model:
- 128-dimensional face encoding for each person
- Euclidean distance-based matching
- High accuracy with minimal false positives
3. KNN Classification
Uses K-Nearest Neighbors (KNN) algorithm for final classification:
- Fast prediction time
- Works well with small to medium datasets
- Easy to update with new faces
- No complex training required
4. Web Interface
Built with Flask framework providing:
- Face registration portal for new users
- Live attendance monitoring
- Attendance history and logs
- Simple, intuitive UI for administrators
Technical Architecture
Detection Pipeline
- Frame Capture: OpenCV captures video frames from webcam
- Preprocessing: Converts to grayscale and applies histogram equalization
- Face Detection: Haar Cascade detects faces in frame
- Feature Extraction: Face Recognition API generates 128-D encodings
- Classification: KNN model predicts identity
- Logging: Attendance recorded with timestamp
Technology Stack
- Python 3: Core programming language
- OpenCV: Real-time computer vision operations
- face_recognition: Face encoding and recognition
- NumPy: Numerical computations and array operations
- Flask: Web framework for user interface
- scikit-learn: KNN classifier implementation
How It Works
Registration Phase
- User enters their name in the web interface
- System captures multiple face images from different angles
- Face encodings are generated and stored
- KNN model is retrained with new data
Attendance Phase
- System continuously captures frames from webcam
- Detected faces are encoded in real-time
- KNN classifier predicts the person’s identity
- First detection of the day logs attendance with timestamp
- Results displayed on web interface
Installation & Setup
Requirements
- Python 3.6+
- Webcam or camera access
- Modern web browser
Quick Start
# Clone the repository
git clone https://github.com/rishav-dahal/Face-Recognition-Based-Attendance-System.git
cd Face-Recognition-Based-Attendance-System
# Create virtual environment
python -m venv venv
source ./venv/bin/activate # On Windows: .\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Train initial model
python train.py
# Start the server
python app.py
# Access the application
# Open browser and go to localhost:8000
Use Cases
Educational Institutions
- Automated attendance in classrooms
- Reduces manual attendance time
- Eliminates proxy attendance
- Generates attendance reports automatically
Corporate Offices
- Employee check-in/check-out tracking
- Access control integration
- Time and attendance management
- Visitor registration
Events & Conferences
- Participant tracking
- Session attendance monitoring
- Registration desk automation
Challenges & Solutions
Challenge 1: Varying Lighting Conditions
Problem: Face recognition accuracy drops in poor or inconsistent lighting.
Solution:
- Applied histogram equalization for consistent brightness
- Captured multiple training images under different lighting
- Used adaptive threshold techniques
Challenge 2: Multiple Faces in Frame
Problem: Detecting and recognizing multiple people simultaneously.
Solution:
- Implemented batch processing for multiple face encodings
- Used spatial filtering to prevent duplicate logging
- Optimized detection region to reduce false positives
Challenge 3: Real-Time Performance
Problem: Balancing accuracy with processing speed.
Solution:
- Used Haar Cascade for fast initial detection
- Processed every 3rd frame for recognition (optimization)
- Implemented multithreading for parallel processing
Future Enhancements
- Deep Learning Models: Integrate CNN-based face recognition for improved accuracy
- Mobile App: Develop Android/iOS apps for mobile attendance
- Cloud Storage: Store attendance data in cloud databases
- Anti-Spoofing: Add liveness detection to prevent photo-based fraud
- Analytics Dashboard: Visualize attendance patterns and statistics
- Multi-Camera Support: Handle multiple camera feeds simultaneously
Technical Learnings
This project provided hands-on experience with:
- Computer vision fundamentals and OpenCV
- Machine learning classification with KNN
- Real-time video processing optimization
- Flask web application development
- Model serialization and deployment
- Face recognition algorithms and their limitations
Conclusion
The Face Recognition Attendance System demonstrates how AI and computer vision can automate manual processes effectively. By combining Haar Cascade detection, Face Recognition API, and KNN classification, the system achieves a balance between accuracy, speed, and ease of use.
This project serves as a foundation for more advanced attendance systems and can be extended with additional features like liveness detection, cloud integration, and mobile support.
GitHub Repository: Face-Recognition-Based-Attendance-System
Live Demo: attendance-system-blue.vercel.app