An end-to-end, real-time face recognition attendance system using computer vision and machine learning. Built with OpenCV and K-Nearest Neighbors (KNN) algorithm, this system implements a complete pipeline from dataset creation to face recognition and CSV-based attendance logging, offering a contactless, cost-effective alternative to manual attendance and expensive biometric systems.
SmartFace Attendance is an intelligent, automated attendance management system that leverages facial recognition technology to eliminate manual attendance processes. By capturing and analyzing facial features in real-time, the system provides accurate, efficient, and hygienic attendance tracking suitable for educational institutions, workplaces, and small businesses.
- 100+ Face Samples per User: Robust dataset creation ensuring high recognition accuracy
- Real-Time Recognition: Instant face detection and identification using webcam
- Multi-Face Detection: Simultaneous detection of multiple faces in frame
- Feature Vector Engineering: 3,750-dimensional feature vectors (75Γ50 pixel grayscale images)
- KNN Classification: Optimized K=5 neighbors for accurate recognition
- CSV-Based Logging: Daily attendance records with timestamps for easy integration
- Validated Performance: Tested under multiple lighting conditions with consistent accuracy
- Contactless Operation: Hygienic, touchless attendance marking
Benefits:
- Eliminate manual attendance registers and roll calls
- Reduce class time wasted on attendance (5-10 minutes per session)
- Prevent proxy attendance and buddy punching
- Generate automated attendance reports for administration
- Track student attendance patterns for academic intervention
Impact: A class of 50 students taking 2 minutes for manual attendance = 100 minutes/day saved across the institution
Benefits:
- Replace expensive biometric systems or RFID card readers
- Accurate time-in/time-out tracking for payroll
- Eliminate buddy punching and time theft
- Seamless integration with HR management systems
- Professional, modern attendance solution
Impact: Reduces attendance fraud, improves payroll accuracy, and saves HR administrative time
Benefits:
- Affordable attendance solution without capital investment
- Easy to set up and maintain
- Scalable as business grows
- Professional appearance for clients and employees
- No ongoing subscription or maintenance costs
Impact: Professional attendance tracking at fraction of commercial system costs
Benefits:
- Quick participant check-in for sessions
- Accurate attendance records for certification
- Reduced administrative overhead
- Professional image for training programs
Limitation: Not ideal for large events/conferences where pre-registration of all attendees is impractical
- Face Detection: Haar Cascade Classifier (OpenCV pre-trained model)
- Feature Engineering: 3,750-dimensional vectors (75Γ50 grayscale images)
- Classification: K-Nearest Neighbors (K=5, optimized through testing)
- Data Storage: Pickle files for face data, CSV for attendance logs
- Dataset Creation: Captures 100 face samples per user at 5-frame intervals
- Feature Extraction: Converts faces to grayscale, resizes to 75Γ50, flattens to 3,750D vectors
- Training: KNN model learns from stored face vectors
- Recognition: Real-time face detection β feature extraction β KNN prediction
- Validation: Ensures exactly ONE face present before allowing attendance
- Logging: Records name and timestamp to daily CSV files
1. No Face: β "No face detected" (attendance disabled)
2. More than one face β "Multiple faces detected!" (attendance disabled)
3. Exactly one face β "Press 'o' to mark attendance" (attendance enabled)Why 100 samples? Captures diverse angles, expressions, and lighting variations for robust recognition.
Why K=5? Tested values 3, 5, 7, 9 - K=5 provided best accuracy/robustness balance.
Why grayscale? Removes color dependency, focuses on facial structure, reduces computational load.
Quick Setup: See QUICKSTART.md for rapid installation and usage.
Installation:
git clone https://github.com/patelritiq/SmartFace-Attendance.git
cd SmartFace-Attendance
pip install -r requirements.txtRegister Users:
cd src
python Dataset.pyMark Attendance:
cd src
python Attendance.py---## Project Structure π
SmartFace-Attendance/
βββ src/ # Source code
β βββ Dataset.py # User registration & dataset creation
β βββ Attendance.py # Real-time attendance system
βββ models/ # Machine learning models
β βββ haarcascade_frontalface_default.xml # Face detection model
βββ assets/ # UI resources
β βββ bg.png # Background image
βββ data/ # Training data storage
β βββ .gitkeep # Keep folder in git
β βββ faces_data.pkl # Face feature vectors (ignored)
β βββ names.pkl # User names (ignored)
βββ Attendance/ # Attendance logs
β βββ .gitkeep # Keep folder in git
β βββ Attendance_DD-MM-YYYY.csv # Daily attendance files (ignored)
βββ .gitignore # Git ignore rules
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
βββ README.md # Project documentation
βββ QUICKSTART.md # Quick setup guide
Note: Personal data files (.pkl, .csv) are excluded from git via .gitignore for privacy.
- Local Storage: All data stays on your system (no cloud)
- User Control: Users can delete their data anytime
- Privacy Compliant: Follows data protection best practices
Recommendations:
- Obtain user consent before collecting face data
- Secure the
data/folder with appropriate permissions - Regularly backup attendance records
- Comply with local regulations (GDPR, etc.)
Limitations:
- Not for high-security applications (banking, government)
- Can be fooled by high-quality photos (no liveness detection)
- Performance degrades with significant appearance changes
Current Limitations:
- Photo spoofing (no liveness detection)
- Appearance changes affect recognition (beard, glasses)
- Lighting dependency (poor performance in darkness)
- Windows-only text-to-speech
Planned Enhancements:
- Liveness detection (blink/head movement)
- Web-based dashboard
- Database backend
- Mobile app
- Admin panel
- Multi-format export (PDF, Excel, JSON)
Contributions are welcome to improve functionality, accuracy, and user experience!
- Fork the repository
- Create a feature branch:
git checkout -b feature/YourFeature - Commit changes:
git commit -m 'Add YourFeature' - Push to branch:
git push origin feature/YourFeature - Open a Pull Request
- Implement multi-face validation
- Add liveness detection
- Create web-based interface
- Improve recognition accuracy
- Add database integration
- Cross-platform compatibility improvements
- Documentation enhancements
This project is licensed under the MIT License - see the LICENSE file for details.
Key Points:
- Free to use, modify, and distribute
- Commercial use allowed
- Attribution appreciated
- No warranty provided
Ritik Pratap Singh Patel
Computer Vision & Machine Learning Enthusiast
Project Links:
- GitHub Repository: https://github.com/patelritiq/SmartFace-Attendance
Connect:
- Email: patelritiq@gmail.com
- LinkedIn: linkedin.com/in/patelritiq
- OpenCV Community: For excellent computer vision tools and documentation
- scikit-learn: For robust machine learning algorithms
- Haar Cascade: Pre-trained face detection model
- Open Source Community: For inspiration and resources
This project was developed as a college project demonstrating practical applications of computer vision and machine learning in solving real-world problems. It showcases the complete pipeline from data collection to deployment, emphasizing cost-effective, accessible solutions for attendance management.
Development Year: 2024
Status: Complete and functional
Purpose: Educational demonstration and practical deployment
Transforming attendance management through intelligent face recognition technology. π€β¨