Skip to content

bikram73/Face_Recognition_Attendance_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Face Recognition Attendance System

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.

Features

  • 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

System Requirements

  • Python 3.7 or higher
  • Webcam/Camera device
  • Windows/Linux/macOS operating system
  • Minimum 4GB RAM recommended

Installation Guide

Step 1: Clone or Download the Project

git clone <repository-url>
cd Face-Recognition-Attendance-System

Step 2: Install Python Dependencies

pip install -r requirements.txt

Note: If you encounter issues with dlib installation on Windows, you may need to install Visual Studio Build Tools or use pre-compiled wheels.

Step 3: Verify Installation

Run the camera check to ensure your webcam is working:

python check_camera.py

Detailed Usage Instructions

Step 1: Initial Setup

  1. Ensure all project files are in the same directory
  2. Verify that haarcascade_frontalface_default.xml and haarcascade_eye.xml files are present
  3. Create necessary directories if they don't exist:
    • TrainingImage/ - for storing captured face images
    • TrainingImageLabel/ - for storing trained model files
    • StudentDetails/ - for storing student information
    • Attendance/ - for storing attendance records

Step 2: Run the Main Application

python main.py

Step 3: Using the Menu System

Option 1: Check Camera

  • 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

Option 2: Capture Faces

  • Purpose: Capture training images for new students
  • Process:
    1. Enter Student ID (numeric only)
    2. Enter Student Name (alphabetic only)
    3. Position your face in front of the camera
    4. The system will automatically capture 100+ images
    5. Images are saved as Name.ID.ImageNumber.jpg in TrainingImage/ folder
    6. 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

Option 3: Train Images

  • Purpose: Create the face recognition model from captured images
  • Process:
    1. Automatically processes all images in TrainingImage/ folder
    2. Extracts facial features using LBPH algorithm
    3. Creates Trainner.yml file in TrainingImageLabel/ folder
    4. Shows progress counter during training
  • Requirements: Must have captured images using Option 2 first
  • Duration: Depends on number of images (typically 30-60 seconds)

Option 4: Recognize & Attendance

  • Purpose: Start the attendance marking system
  • Process:
    1. Loads the trained model (Trainner.yml)
    2. Starts webcam feed for real-time recognition
    3. Detects and recognizes faces in the video stream
    4. Displays confidence percentage for each recognition
    5. Marks attendance for recognized faces (confidence > 70%)
    6. Press 'q' to stop and save attendance
  • Output: Creates timestamped CSV file in Attendance/ folder
  • File Format: Attendance_YYYY-MM-DD_HH-MM-SS.csv

Option 5: Quit

  • Safely exits the application

Step 4: Understanding the Output Files

Student Details (StudentDetails/StudentDetails.csv)

Id,Name
1,John
2,Alice
3,Bob

Attendance Records (Attendance/Attendance_YYYY-MM-DD_HH-MM-SS.csv)

Id,Name,Date,Time
1,John,2024-01-15,09:30:25
2,Alice,2024-01-15,09:31:10

File Structure

Face-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

Troubleshooting

Common Issues and Solutions

  1. 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
  2. Face Not Detected

    • Ensure adequate lighting
    • Position face clearly in camera view
    • Check if haarcascade_frontalface_default.xml file exists
  3. Low Recognition Accuracy

    • Capture more training images (100+ recommended)
    • Ensure diverse angles and lighting during capture
    • Retrain the model with new images
  4. Import Errors

    • Verify all dependencies are installed: pip install -r requirements.txt
    • For dlib issues on Windows, install Visual Studio Build Tools
  5. File Permission Errors

    • Run with administrator privileges if needed
    • Check write permissions for output directories

Performance Optimization

  • 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

Technical Details

Algorithms Used

  • Face Detection: Haar Cascade Classifiers
  • Face Recognition: LBPH (Local Binary Pattern Histogram)
  • Image Processing: OpenCV library

Recognition Confidence

  • High Confidence: > 70% (marked as present)
  • Medium Confidence: 30-70% (displayed but not marked)
  • Low Confidence: < 30% (marked as unknown)

Future Enhancements

  • 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

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Review the code comments for technical details
  3. Create an issue in the repository

About

πŸ“±The Face Recognition Attendance System is a Python-based automated attendance management solution that uses computer vision and machine learning to identify individuals through a live webcam feed and record their attendance automatically. The system eliminates the need for manual roll calls, reducing human error & improving efficiency classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages