A comprehensive Python-based face recognition attendance system that automatically detects and recognizes faces from a webcam feed and marks attendance in CSV files. The system uses OpenCV for computer vision tasks and machine learning algorithms for face recognition.
- Real-time Face Detection: Uses Haar Cascade classifiers for accurate face detection
- Face Recognition: Implements LBPH (Local Binary Pattern Histogram) algorithm for face recognition
- Automatic Attendance Marking: Generates timestamped CSV attendance files
- User-friendly Interface: Menu-driven console application
- Student Database Management: Maintains student details in CSV format
- Camera Testing: Built-in camera functionality testing
- Training System: Automated face model training from captured images
- Python 3.7 or higher
- Webcam/Camera device
- Windows/Linux/macOS operating system
- Minimum 4GB RAM recommended
git clone <repository-url>
cd Face-Recognition-Attendance-Systempip install -r requirements.txtNote: If you encounter issues with dlib installation on Windows, you may need to install Visual Studio Build Tools or use pre-compiled wheels.
Run the camera check to ensure your webcam is working:
python check_camera.py- Ensure all project files are in the same directory
- Verify that
haarcascade_frontalface_default.xmlandhaarcascade_eye.xmlfiles are present - Create necessary directories if they don't exist:
TrainingImage/- for storing captured face imagesTrainingImageLabel/- for storing trained model filesStudentDetails/- for storing student informationAttendance/- for storing attendance records
python main.py- Tests your webcam functionality
- Displays live video feed with face detection rectangles
- Press 'q' to quit the camera test
- Useful for verifying camera setup before proceeding
- Purpose: Capture training images for new students
- Process:
- Enter Student ID (numeric only)
- Enter Student Name (alphabetic only)
- Position your face in front of the camera
- The system will automatically capture 100+ images
- Images are saved as
Name.ID.ImageNumber.jpginTrainingImage/folder - Student details are automatically added to
StudentDetails.csv
- Tips:
- Ensure good lighting conditions
- Move your head slightly for different angles
- Keep face clearly visible and centered
- Press 'q' to stop capturing early if needed
- Purpose: Create the face recognition model from captured images
- Process:
- Automatically processes all images in
TrainingImage/folder - Extracts facial features using LBPH algorithm
- Creates
Trainner.ymlfile inTrainingImageLabel/folder - Shows progress counter during training
- Automatically processes all images in
- Requirements: Must have captured images using Option 2 first
- Duration: Depends on number of images (typically 30-60 seconds)
- Purpose: Start the attendance marking system
- Process:
- Loads the trained model (
Trainner.yml) - Starts webcam feed for real-time recognition
- Detects and recognizes faces in the video stream
- Displays confidence percentage for each recognition
- Marks attendance for recognized faces (confidence > 70%)
- Press 'q' to stop and save attendance
- Loads the trained model (
- Output: Creates timestamped CSV file in
Attendance/folder - File Format:
Attendance_YYYY-MM-DD_HH-MM-SS.csv
- Safely exits the application
Id,Name
1,John
2,Alice
3,BobId,Name,Date,Time
1,John,2024-01-15,09:30:25
2,Alice,2024-01-15,09:31:10Face-Recognition-Attendance-System/
βββ main.py # Main application entry point
βββ Capture_Image.py # Face capture functionality
βββ Train_Image.py # Model training functionality
βββ Recognize.py # Face recognition and attendance
βββ check_camera.py # Camera testing utility
βββ face_recog.py # Alternative recognition script
βββ automail.py # Email functionality (future feature)
βββ requirements.txt # Python dependencies
βββ haarcascade_frontalface_default.xml # Face detection model
βββ haarcascade_eye.xml # Eye detection model
βββ TrainingImage/ # Captured face images
βββ TrainingImageLabel/ # Trained model files
βββ StudentDetails/ # Student information
βββ Attendance/ # Attendance records
βββ README.md # This file
-
Camera Not Working
- Check if camera is connected and not used by other applications
- Try changing camera index in code (0, 1, 2, etc.)
- Ensure camera permissions are granted
-
Face Not Detected
- Ensure adequate lighting
- Position face clearly in camera view
- Check if
haarcascade_frontalface_default.xmlfile exists
-
Low Recognition Accuracy
- Capture more training images (100+ recommended)
- Ensure diverse angles and lighting during capture
- Retrain the model with new images
-
Import Errors
- Verify all dependencies are installed:
pip install -r requirements.txt - For dlib issues on Windows, install Visual Studio Build Tools
- Verify all dependencies are installed:
-
File Permission Errors
- Run with administrator privileges if needed
- Check write permissions for output directories
- For Better Accuracy: Capture 150-200 images per person
- For Faster Processing: Reduce camera resolution in code
- For Multiple People: Ensure distinct facial features in training data
- Face Detection: Haar Cascade Classifiers
- Face Recognition: LBPH (Local Binary Pattern Histogram)
- Image Processing: OpenCV library
- High Confidence: > 70% (marked as present)
- Medium Confidence: 30-70% (displayed but not marked)
- Low Confidence: < 30% (marked as unknown)
- Google Sheets integration for cloud-based attendance
- Email notifications for attendance reports
- Web-based interface
- Mobile app integration
- Advanced deep learning models
- Multi-camera support
- Real-time dashboard
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section above
- Review the code comments for technical details
- Create an issue in the repository