Skip to content

dakshitcodes/face-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Face Recognition Attendance System

A Python-based GUI desktop application that uses real-time face recognition to automatically mark employee attendance. Built with OpenCV, face_recognition, and Tkinter, it records attendance data to an Excel sheet with attendance percentage calculations.


Features

  • Face Recognition Login — Identifies registered employees via webcam and marks attendance instantly.
  • New User Registration — Capture a face photo via webcam and store employee details.
  • Duplicate Prevention — Prevents marking attendance more than once per day for the same employee.
  • Attendance Percentage — Automatically calculates attendance percentage based on working days (excluding Sundays and Indian public holidays).
  • Excel-Based Storage — All employee and attendance data is persisted in .xlsx files — no database required.

Project Structure

PythonProject/
│
├── app.py                  # Main application entry point
├── employees.xlsx          # Stores registered employee records (ID, Name)
├── attendance.xlsx         # Stores attendance logs (Date, Time, %, etc.)
├── faces/                  # Directory storing registered face images
│   └── <empID>_<name>.jpg
└── README.md

Requirements

Python Version

  • Python 3.8+

Dependencies

Install all dependencies using pip:

pip install opencv-python face_recognition numpy pandas openpyxl holidays

Note: face_recognition requires dlib. On Windows, it is recommended to install a prebuilt wheel or use CMake + Visual Studio Build Tools.

pip install cmake
pip install dlib
pip install face_recognition

Hardware

  • A working webcam (built-in or external).

Getting Started

  1. Clone the repository

    git clone <your-repo-url>
    cd PythonProject
  2. Install dependencies

    pip install opencv-python face_recognition numpy pandas openpyxl holidays
  3. Run the application

    python app.py

How to Use

Registering a New Employee

  1. Click "New User Registration" on the main window.
  2. Enter the Employee ID and Name.
  3. Click "Register and Capture Face".
  4. A webcam window will open — look at the camera.
  5. Press SPACE to capture your face or ESC to cancel.
  6. The employee is saved to employees.xlsx and their face image to the faces/ folder.

Marking Attendance (Login)

  1. Click "Login (Face Recognition)" on the main window.
  2. The webcam activates and scans for registered faces.
  3. If a match is found:
    • A green rectangle appears around the face.
    • Attendance is marked in attendance.xlsx with the current date, time, and attendance percentage.
    • A success dialog is shown.
  4. If the face is unrecognized, a red rectangle with "Unknown" is displayed.
  5. Press ESC to close the webcam window manually.

Attendance Data

The attendance.xlsx file tracks the following fields:

Column Description
S.No. Serial number
Employee ID Unique identifier for the employee
Name Employee name
Date Date attendance was marked (DD-MM-YYYY)
Time Time attendance was marked (HH:MM:SS)
Attendance Status — always Present when marked
Attendance Percentage % of working days present since Jan 1st

Working days exclude Sundays and Indian public holidays (via the holidays library).


Configuration

Constant Default Value Description
EMPLOYEES_FILE employees.xlsx Excel file for employee records
ATTENDANCE_FILE attendance.xlsx Excel file for attendance logs
FACES_DIR faces/ Directory for stored face images

These can be changed at the top of app.py.


Known Limitations(will improve with time!! stay tuned)

  • Only one face is processed per recognition session (first match wins).
  • Attendance percentage is calculated from January 1st of the current year.
  • Face recognition accuracy may decrease in low-light conditions.
  • face_recognition library can be slow on machines without a GPU.

Tech Stack

Technology Purpose
Python Core language
OpenCV (cv2) Webcam access & image processing
face_recognition Face encoding & matching
Tkinter GUI framework
Pandas Excel read/write operations
OpenPyXL Excel file engine for pandas
holidays Indian public holiday detection
NumPy Numerical operations

License

This project is created for academic purposes as part of a 6th Semester Python Lab.

About

A terminal based face recognition system which captures the face in real time and marks the attendance, updates the attendance and user record simultaneously

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages