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.
- 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
.xlsxfiles — no database required.
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
- Python 3.8+
Install all dependencies using pip:
pip install opencv-python face_recognition numpy pandas openpyxl holidaysNote:
face_recognitionrequiresdlib. 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
- A working webcam (built-in or external).
-
Clone the repository
git clone <your-repo-url> cd PythonProject
-
Install dependencies
pip install opencv-python face_recognition numpy pandas openpyxl holidays
-
Run the application
python app.py
- Click "New User Registration" on the main window.
- Enter the Employee ID and Name.
- Click "Register and Capture Face".
- A webcam window will open — look at the camera.
- Press
SPACEto capture your face orESCto cancel. - The employee is saved to
employees.xlsxand their face image to thefaces/folder.
- Click "Login (Face Recognition)" on the main window.
- The webcam activates and scans for registered faces.
- If a match is found:
- A green rectangle appears around the face.
- Attendance is marked in
attendance.xlsxwith the current date, time, and attendance percentage. - A success dialog is shown.
- If the face is unrecognized, a red rectangle with "Unknown" is displayed.
- Press
ESCto close the webcam window manually.
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
holidayslibrary).
| 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.
- 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_recognitionlibrary can be slow on machines without a GPU.
| 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 |
This project is created for academic purposes as part of a 6th Semester Python Lab.