A modern web-based attendance tracking system using facial recognition technology built with React, TypeScript, and face-api.js.
This is a step-by-step attendance system that combines QR code verification and face recognition to mark student attendance automatically.
- β QR Code class verification
- π€ Face recognition for student identification
- π Real-time attendance marking
- π Firebase integration for data storage
- π± Streamlit web interface
- Students must be registered using
face_recognizer.pyfirst - Firebase service account credentials (
firebase-service-account.json) - Camera access for QR scanning and face recognition
# Activate virtual environment
source macenv/bin/activate
# Run the Streamlit application
streamlit run finalserver.py-
Generate QR Code (using separate script):
python3 generate_qr.py cs104
- This creates a QR code file (e.g.,
qr_cs104.png) - Print or display the QR code for students to scan
- This creates a QR code file (e.g.,
-
Scan QR Code or Manual Entry:
- Students click "Start QR Camera Scan" and point camera at QR code
- Alternative: Enter class ID manually (e.g., "cs104")
- System verifies/creates class in Firebase
- Classes are auto-created if they don't exist
-
Automatic Student Detection:
- Camera activates for face recognition
- System loads all registered students for the class
- Real-time face detection and matching
-
Attendance Marking:
- Requires 5 consecutive detections for accuracy
- Prevents duplicate attendance (one per day)
- Shows success message and balloons animation
- Stores attendance with timestamp in Firebase
- Recognition Tolerance: Adjust slider (0.3-0.8)
- Lower = Stricter matching
- Higher = More lenient matching
- Stop Recognition: Click stop button anytime
- Back Navigation: Return to QR scan step
1. QR Code Scan β 2. Class Verification β 3. Face Recognition β 4. Attendance Marked
- "No students registered": Use
face_recognizer.pyto register students first - "Error verifying class code": Classes are auto-created, check Firebase connection
- Camera not working: Check camera permissions
- QR code not detected: Ensure good lighting and QR code visibility
- Face not recognized: Adjust tolerance or re-register student
python3 generate_qr.py cs104
python3 generate_qr.py math101 --output math_class_qr.pngpython3 face_recognizer.py --mode register --class_id cs104 --student_id 123 --name "John Doe"python3 face_recognizer.py --mode detect --class_id cs104Firebase Firestore:
/classes/{class_id}/
βββ students/{student_id}
β βββ name, class_id, registered_at
β βββ encodings/{frame_id}
β βββ encoding[], frame_number
βββ attendance/{date}/
βββ students/{student_id}
βββ marked_at, status, student_name
- Class verification before attendance
- Multiple face encodings for accuracy
- Consecutive detection requirement
- Duplicate attendance prevention
- Firebase security rules
- Ensure good lighting for face recognition
- Position camera at eye level
- Process every 3rd frame for performance
- Use tolerance 0.4-0.6 for best results
- Limit to 30 students per class for optimal speed
All dependencies in requirements.txt:
- streamlit
- opencv-python
- face-recognition
- qrcode[pil]
- pyzbar
- firebase-admin
- numpy
- pillow
- Check Firebase console for data verification
- Monitor Streamlit logs for debugging
- Ensure all students are properly registered
- Test QR codes before class sessions
- Face Registration: Register users with facial data for recognition
- Live Attendance Scanning: Real-time face detection and attendance marking via webcam
- Firebase Integration: Cloud storage for attendance records and user data
- Adjustable Recognition Threshold: Customize confidence levels for attendance marking
- Session Management: Track attendance per session with clear statistics
- Responsive UI: Clean, user-friendly interface for desktop and mobile
- Frontend: React 18, TypeScript, Vite
- Face Recognition: face-api.js (TensorFlow.js)
- Backend: Firebase (Firestore, Authentication)
- Styling: CSS Modules
- Build Tool: Vite
-
Clone the repository:
git clone https://github.com/GabiYamato/AttendanceSystem.git cd AttendanceSystem/v4 -
Install dependencies:
npm install
-
Set up Firebase:
- Create a Firebase project at Firebase Console
- Enable Firestore and Authentication
- Copy your Firebase config to
src/firebase.ts
-
Download face-api.js models:
- Models are already included in
public/models/ - If needed, download from face-api.js GitHub
- Models are already included in
-
Start the development server:
npm run dev
- Login: Access the system with your credentials
- Register Faces: Add new users by capturing their facial data
- Live Scanning: Start the camera to detect and record attendance in real-time
- View Records: Check attendance history on the dashboard
v4/
βββ public/
β βββ models/ # face-api.js model files
β βββ vite.svg
βββ src/
β βββ components/ # React components
β β βββ AttendanceSystem.tsx
β β βββ Dashboard.tsx
β β βββ LiveAttendance.tsx
β β βββ LoginPage.tsx
β β βββ RegistrationPage.tsx
β βββ hooks/ # Custom React hooks
β β βββ useCamera.ts
β β βββ useFaceAPI.ts
β βββ services/ # Firebase services
β β βββ firebaseService.ts
β βββ types/ # TypeScript type definitions
β β βββ index.ts
β βββ App.tsx
β βββ firebase.ts # Firebase configuration
β βββ main.tsx
βββ package.json
βββ tsconfig.json
βββ vite.config.ts
npm run dev: Start development servernpm run build: Build for productionnpm run preview: Preview production buildnpm run lint: Run ESLint
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License.
- Ensure camera permissions are granted for live scanning
- Models load asynchronously; wait for loading to complete before scanning
- Adjust recognition threshold