Skip to content

jasonjiang8866/attendance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Attendance System with Face Recognition

A real-time attendance tracking system that uses facial recognition technology to automatically identify and record attendance. The system consists of a Python FastAPI backend with face recognition capabilities and an Angular frontend for user interaction.

πŸš€ Features

  • Real-time Face Recognition: Uses OpenCV and face_recognition library for accurate face detection and identification
  • Live Video Streaming: Real-time webcam feed with face detection overlay
  • Web-based Interface: Modern Angular frontend with Material Design components
  • RESTful API: FastAPI backend for handling video streams and face recognition processing
  • Automatic Attendance: Seamless attendance tracking through facial recognition
  • Known Face Management: System to encode and store known faces for recognition

πŸ“Έ User Interface Screenshots

Face Registration

The system provides an intuitive interface for registering new faces. Users can upload a clear photo along with their name to register for attendance tracking.

Face Registration Interface

Live Attendance Tracking

The main attendance interface features a live video feed with real-time face recognition capabilities, plus manual attendance options as a fallback.

Take Attendance Interface

Attendance Records

View and manage attendance history with a clean, organized interface showing timestamps and recent attendance activities.

Attendance Records Interface

πŸ› οΈ Technology Stack

Backend

  • FastAPI: Modern Python web framework for building APIs
  • OpenCV: Computer vision library for image processing
  • face_recognition: Face recognition library built on dlib
  • Uvicorn: ASGI server for running the FastAPI application

Frontend

  • Angular 16: Modern web application framework
  • Angular Material: Material Design components for Angular
  • Bootstrap: CSS framework for responsive design
  • TypeScript: Typed superset of JavaScript

πŸ“‹ Prerequisites

Python Dependencies

  • Python 3.7+
  • OpenCV (cv2)
  • face_recognition
  • FastAPI
  • Uvicorn
  • NumPy

Node.js Dependencies

  • Node.js 16+
  • Angular CLI
  • npm or yarn

πŸ”§ Installation

Option 1: Automatic Setup (Recommended)

We provide automated setup scripts that use uv for fast and reliable Python dependency management:

# Clone the repository
git clone https://github.com/jasonjiang8866/attendance.git
cd attendance

# Run the automated setup script (Python)
python setup.py

# Or use the shell script alternative
chmod +x setup.sh
./setup.sh

The setup script will:

  • Install uv package manager if not already installed
  • Create a virtual environment and install all Python dependencies
  • Install face recognition models
  • Create the required 'faces' directory

Option 2: Manual Setup

1. Clone the Repository

git clone https://github.com/jasonjiang8866/attendance.git
cd attendance

2. Backend Setup

# Install Python dependencies manually
pip install fastapi uvicorn opencv-python face-recognition numpy jinja2

# Create a 'faces' directory and add known face images
mkdir faces
# Add images of known people to the faces directory (format: name.jpg)

3. Frontend Setup

# Navigate to the Angular application
cd UI/i-attendance

# Install dependencies
npm install

# Build the application
npm run build

πŸš€ Usage

Running the Backend

If you used the automated setup (recommended):

# From the repository root
uv run python main.py

If you used manual installation:

# From the repository root
python main.py

The FastAPI server will start on http://127.0.0.1:8000

Running the Frontend

# Navigate to the Angular application
cd UI/i-attendance

# Start the development server
npm start

The Angular application will be available on http://localhost:4200

API Endpoints

  • GET /: Main interface with live video stream
  • GET /video_feed: Video streaming endpoint for face recognition

πŸ“ Project Structure

attendance/
β”œβ”€β”€ README.md                 # This file
β”œβ”€β”€ main.py                   # FastAPI backend application
β”œβ”€β”€ face_recognizor.py        # Face recognition logic and processing
β”œβ”€β”€ setup.py                  # Automated Python setup script for developers
β”œβ”€β”€ setup.sh                  # Automated shell setup script for developers
β”œβ”€β”€ pyproject.toml           # Python project configuration and dependencies
β”œβ”€β”€ .python-version          # Python version specification for uv
β”œβ”€β”€ templates/                # HTML templates for the web interface
β”‚   └── index.html           # Main template for video streaming
β”œβ”€β”€ UI/                      # Frontend application
β”‚   └── i-attendance/        # Angular application
β”‚       β”œβ”€β”€ src/             # Angular source code
β”‚       β”œβ”€β”€ package.json     # Node.js dependencies
β”‚       └── README.md        # Angular-specific README
β”œβ”€β”€ faces/                   # Directory for known face images (created by setup)
β”œβ”€β”€ .gitignore              # Git ignore rules
└── known_face_*.dat        # Generated face encoding files

🎯 How It Works

  1. Face Encoding: The system scans the faces/ directory and creates encodings for all known faces
  2. Real-time Detection: Uses webcam feed to detect faces in real-time
  3. Recognition: Compares detected faces with known face encodings
  4. Confidence Scoring: Provides confidence percentage for face matches
  5. Visual Feedback: Displays bounding boxes and names on the video feed

πŸ“ Adding New Faces

  1. Add high-quality images of people to the faces/ directory
  2. Name the files with the person's name (e.g., john_doe.jpg)
  3. Restart the application to update the face encodings

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.

⚠️ Important Notes

  • Ensure good lighting conditions for optimal face recognition accuracy
  • The system requires camera permissions to function properly
  • Face recognition accuracy depends on the quality of images in the faces/ directory
  • For production use, consider implementing additional security measures and data protection

πŸ”§ Troubleshooting

Common Issues

  • Camera not detected: Ensure your webcam is connected and not being used by other applications
  • Face recognition not working: Check if the faces/ directory contains images and face encodings are generated
  • Performance issues: Reduce video frame size or adjust processing frequency in the code

Requirements Installation Issues

If you encounter issues installing face_recognition:

# On Ubuntu/Debian
sudo apt-get install cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-dev

# On macOS
brew install cmake

πŸ“ž Support

For support and questions, please open an issue in the GitHub repository.

About

a handy face attendance system for taking attendance just using face

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors