Overview
A production-ready attendance system that detects faces from a webcam, recognizes registered users, and logs timestamps to CSV/Excel.
Supports offline usage and works on low-spec laptops.
Features
- Real-time face detection with Haar cascades
- Face recognition using LBPH
- Auto mark in/out with timestamp
- Duplicate prevention within a grace window
- CSV and Excel export
- Admin CLI to register faces
Tech Stack
- Python 3.10+
- OpenCV
- Numpy
- Pandas
Project Structure
attendance/
├─ data/ # Face datasets and trained model
├─ logs/ # Attendance CSV/Excel
├─ register.py # Register new faces
├─ train.py # Train recognizer
├─ run.py # Start attendance app
└─ requirements.txt
Setup
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
Usage
Register at least 30 images per person with unique IDs:
python register.py --person-id 1001 --name "Alice"
Train the model:
python train.py
Run attendance system:
python run.py --export excel
Sample CSV
name,person_id,action,timestamp
Alice,1001,IN,2025-09-01T09:03:11
Alice,1001,OUT,2025-09-01T17:34:22
Notes
- Ensure good lighting for better recognition accuracy.
- Re-train the model after adding/removing users.