Real-time face detection and recognition system
A system providing real-time face recognition through camera integration and a web-based dashboard.
- Real-time camera integration
- Face recognition using Hugging Face models
- Web-based monitoring dashboard
- Face registration and management
- Multi-sample face matching for improved accuracy
- Real-time statistics (detected faces, recognized faces, FPS)
- Backend: Python 3.9+, FastAPI, OpenCV
- ML: InsightFace (buffalo_l), PyTorch
- Frontend: React 19, Vite, Tailwind CSS, React Router
- Testing: Playwright E2E Testing
- DevOps: Git, GitHub
- PRD (Product Requirements)
- Project Plan
- Learning Workbook - Technical learning guide for project managers
- API Guide - FastAPI server usage guide
- Troubleshooting Guide - Installation and execution issues
faceReco/
βββ backend/ # Backend server
β βββ app.py # Main application
β βββ models/ # ML model modules
β β βββ face_detection.py # Haar Cascade face detection
β β βββ face_recognition.py # InsightFace face recognition
β β βββ face_database.py # Face database management
β βββ camera/ # Camera processing module
β βββ api/ # API endpoints
β βββ data/ # Face database
β β βββ face_database.json # Metadata
β β βββ embeddings/ # Face embeddings (512-dim)
β β βββ faces/ # Face images
β βββ requirements.txt # Python dependencies
βββ frontend/ # Frontend (React + Vite)
β βββ src/
β β βββ components/ # UI components
β β βββ pages/ # Pages (Dashboard, FaceRegistration, FaceList)
β β βββ services/ # API services
β β βββ utils/ # Utilities
β βββ tests/ # Playwright E2E tests
β βββ package.json
βββ docs/ # Documentation
βββ tests/ # Test code
βββ PRD.md # Product Requirements
βββ PROJECT_PLAN.md # Project Plan
βββ README.md # This file
Current Status: Milestone 5 - Web Dashboard Development In Progress π§
Milestone 1: Initial Project Setup β
- GitHub repository creation
- Project directory structure setup
- Python virtual environment configuration
- Basic dependency package installation
- Documentation (PRD, PROJECT_PLAN, README)
Milestone 2: Camera Integration and Basic Face Detection β
- OpenCV camera handler implementation
- Real-time video stream processing
- Haar Cascade face detection implementation
- Face region bounding box display
- Unit test creation
Milestone 3: ML Model Integration β
- InsightFace buffalo_l model selection
- FaceRecognizer class implementation (face embedding extraction)
- FaceDatabase class implementation (face database management)
- Face registration feature implementation
- Face recognition and matching feature implementation
- Unit test creation
Milestone 4: Backend API Development β
- FastAPI project initialization
- API endpoint design and implementation
- CORS configuration
- Real-time video streaming API
- Face registration/query/deletion API
- API documentation (Swagger UI)
- Real-time statistics API
Milestone 5: Web Dashboard Development π§
- React + Vite frontend project initialization
- Basic layout structure (Header, Sidebar, Layout)
- Page components (Dashboard, FaceRegistration, FaceList)
- API client setup (Axios)
- Real-time camera monitoring with statistics
- Face registration page with camera capture
- Face list management with duplicate detection
- Playwright E2E testing setup
- Comprehensive testing and optimization
- Integration testing and performance optimization (Milestone 5)
- Deployment documentation and Docker containerization (Milestone 6)
- Python 3.8 or higher
- Git
- Webcam (for camera features)
- Node.js 18+ (for frontend)
-
Clone Repository
git clone https://github.com/quirinal36/faceReco.git cd faceReco -
Create and Activate Python Virtual Environment
# Create virtual environment python3 -m venv venv # Activate virtual environment (Linux/Mac) source venv/bin/activate # Activate virtual environment (Windows) venv\Scripts\activate
-
Install Dependencies
cd backend # Option 1: Production environment (recommended) pip install -r requirements.txt # Option 2: Minimal install (for quick testing) pip install -r requirements-minimal.txt # Option 3: Development environment (for developers) pip install -r requirements-dev.txt
Requirements File Descriptions:
requirements.txt- Production environment (full features)requirements-minimal.txt- Minimal environment (fast install, limited features)requirements-dev.txt- Development environment (includes testing, linting, documentation tools)
Important: InsightFace installation issues may occur on Windows.
- Recommended Solution: Refer to Solution 1 or 2 in Troubleshooting Guide
- Install Visual Studio Build Tools or use Conda environment
-
Verify Installation
# Check installed packages python test_installation.pyNote: On first run, InsightFace buffalo_l model will be downloaded automatically (~600MB)
Method 1: Using npm scripts (Most convenient)
# Install frontend dependencies (first time only)
npm run install-all
# Run backend + frontend simultaneously
npm run devMethod 2: Using run scripts
# Windows
start-dev.bat
# Linux/Mac
./start-dev.shAfter server starts:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
Virtual environment activation required:
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
cd backendpython app.py --mode register --camera-id 0- Spacebar: Capture face
- Enter name and press Enter
- q: Exit
python app.py --mode face_recognition --camera-id 0- Registered faces: Green box + name + confidence
- Unregistered faces: Red box + "Unknown"
- q: Exit
python app.py --mode face_detection --camera-id 0python app.py --mode camera --camera-id 0# Method 1: Using app.py
python app.py --mode server
# Method 2: Direct server.py execution
python server.pyAfter server starts:
- API Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Health Check: http://localhost:8000/api/health
API Endpoints:
POST /api/face/register- Register faceGET /api/faces/list- List registered facesDELETE /api/face/{id}- Delete faceGET /api/camera/stream- Real-time video streamingGET /api/camera/stats- Real-time statisticsPOST /api/faces/merge/{name}- Merge duplicate faces
For detailed usage, see API Guide.
# Test camera handler
python -m camera.camera_handler
# Face detection demo
python -m models.face_detection
# Face recognition module test
python -m models.face_recognitionNotes:
- Webcam access permission required
- Press 'q' to exit the program
- Camera access may be restricted in WSL environments
-
Code Formatting
# Code formatting with Black black backend/ -
Running Tests
# Backend tests with pytest pytest tests/ # Frontend E2E tests with Playwright cd frontend npx playwright test
- Create or select an issue
- Create new branch (
git checkout -b feature/issue-name) - Write code and tests
- Commit and push
- Create Pull Request
- Python: Follow PEP 8, use Black formatter
- Write docstrings for functions and classes
- Write test code (recommended)
- React: Use functional components with hooks
- Backend: pytest for unit tests
- Frontend: Playwright for E2E tests
- Test coverage goal: >80%
Project progress can be tracked at GitHub Issues.
- Milestone 1: Initial Project Setup β
- Milestone 2: Camera Integration and Basic Face Detection β
- Milestone 3: ML Model Integration β
- Milestone 4: Backend API Development β
- Milestone 5: Web Dashboard Development π§
- Milestone 6: Integration and Deployment Preparation
The main dashboard provides real-time face detection and recognition with live statistics including detected faces count, recognized faces count, and processing speed (FPS).
Register new faces through the web interface with camera capture and multi-language support.
View and manage all registered faces with options for deletion and duplicate detection.
- Register multiple photos of the same person for improved accuracy
- Automatic duplicate detection and merging
- Uses maximum similarity among all samples for recognition
- Live face detection count
- Recognition success rate
- Processing speed (FPS)
- Updated every second
- Playwright E2E tests for frontend
- Webcam mocking for testing without hardware
- API integration tests
- Multi-language support (English/Korean)
- Easy language switching
- Localized UI components
- Clone the repository and install dependencies (see Installation)
- Start both backend and frontend servers:
npm run dev
- Access the web dashboard at http://localhost:5173
- Navigate to Face Registration page from the sidebar
- Allow camera access when prompted
- Position your face in the camera view
- Click Capture button to take a photo
- Enter a name for the person
- Click Register to save the face
Tips:
- Ensure good lighting for better recognition
- Capture multiple angles for improved accuracy
- Keep your face centered in the frame
- Go to the Dashboard page
- The system will automatically start detecting and recognizing faces
- View real-time statistics:
- Detected Faces: Total faces detected in the current frame
- Recognized Faces: Number of faces matched with registered persons
- FPS: Processing speed in frames per second
Camera Feed:
- Green boxes: Recognized faces (with name and confidence score)
- Red boxes: Unregistered/unknown faces
- Navigate to Face List page
- View all registered faces with their details
- Use the Delete button to remove faces
- System automatically detects duplicate entries
The system includes Playwright E2E tests that work without physical hardware:
cd frontend
npm testFor developers integrating with the backend API:
- API Documentation: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- See API Guide for detailed endpoint documentation
TBD
Last Updated: 2026-02-09