A simple facial recognition attendance system demo built with React, FastAPI, and OpenCV LBPH.
- Dual Enrollment - Webcam or file upload
- Real-time Recognition - Automatic attendance marking
- Live Dashboard - Stats and records
- Google Sheets - Auto data sync
- Responsive - Works on all devices
Frontend: React, Tailwind CSS, React Webcam
Backend: FastAPI, OpenCV (LBPH), Google Sheets API
Algorithm: LBPH (Local Binary Patterns Histograms)
- Python 3.11+
- Node.js 16+
- Google Sheets API credentials
Backend:
cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend:
cd frontend
npm install
npm startAccess: http://localhost:3000
Google Sheets Setup
- put the google_sheets_creds.json file(downloaded from https://console.cloud.google.com) and store it in a credentials folder in the backend directory and add the required path and spreadsheet ID from google sheets also share the spreadsheet with the service account email created
Procedure
- Click "New Project" → add project name and → Create
- Enable Google Sheets API from library
- from API & services -> create credentials -> Service Account and grant editor access after creation
- from the service account create key in JSON format and create(automatic download to system)
- Enroll - Capture or upload face photo
- Approve Entry - Face camera for recognition
- Dashboard - View attendance stats
├── backend/ # FastAPI + OpenCV
│ ├── app/
│ ├── data/
│ └── credentials/
└── frontend/ # React UI
└── src/
POST /api/enroll/webcam- Enroll from cameraPOST /api/enroll/file- Enroll from filePOST /api/approve- Mark attendanceGET /api/dashboard/stats- Get statistics
API Docs: http://localhost:8000/docs
Uses LBPH algorithm for face recognition:
- Detects faces with Haar Cascade
- Extracts texture patterns
- Trains on each enrollment
- Recognizes faces in real-time
⭐ Demo project for my learning purposes