A lightweight, dependency-free face recognition system powered by OpenCV's DNN module.
✨ Real-time Detection — Identify faces in live video streams
� Multi-Face Support — Detect and recognize multiple people simultaneously
�📸 Image Processing — Analyze faces in static images with annotations
⚡ Zero Setup — Models download automatically on first run
💪 CPU-Only — No GPU required
🔌 Pure OpenCV — No TensorFlow, no compilation, no complications
🎨 Beautiful UI — Stylish bounding boxes with corner accents and color coding
📊 Live Dashboard — Real-time statistics panel with session metrics
📸 Screenshot Capture — Save snapshots instantly with S key
🎥 Video Recording — Record recognition sessions with R key
👁️ Face Landmarks — Visual facial feature points overlay
📈 Confidence Meters — Visual confidence bars for each detection
🔔 Unknown Alerts — Get notified when unknown persons are detected
⚙️ Adjustable Settings — Fine-tune detection thresholds on-the-fly
💾 Auto-save Outputs — Annotated images saved to output/ directory
| Package | Version |
|---|---|
| Python | 3.7+ |
| OpenCV | 4.9.0 |
| NumPy | 1.26.3 |
git clone https://github.com/yourusername/face-recognition-system.git
cd face-recognition-system
pip install -r requirements.txtCreate a faces/ directory with images of people you want to recognize:
faces/
├── john.jpg
├── sarah.png
└── alex.jpg
Tip: Use filename as the person's name (e.g.,
john.jpg→ recognized as "John")
python main.pySelect your mode:
- Mode 1: Real-time webcam recognition (press
qto quit) - Mode 2: Process a single image file
Real-time Webcam Recognition (Enhanced Mode)
python main.py
# Select option 1| Key | Action |
|---|---|
Q |
Quit application |
S |
Take screenshot |
R |
Toggle video recording |
L |
Toggle face landmarks |
C |
Toggle confidence bars |
T |
Toggle stats panel |
E |
Toggle emotion detection |
A |
Toggle unknown alerts |
] |
Make recognition MORE strict (fewer false positives) |
[ |
Make recognition LESS strict (more lenient) |
Image File Processing
python main.py
# Select option 2
# Provide your image path
# Annotated image saved to output/ directoryView Settings & Statistics
python main.py
# Select option 3 for settings
# Select option 4 for statisticsModel Setup (auto-download on first run)
↓
Directory Scan (faces/ folder)
↓
Face Detection (OpenCV DNN)
↓
Face Recognition (LBPH algorithm)
↓
Results Display (with confidence scores)
| Component | Technology |
|---|---|
| Face Detection | OpenCV DNN + SSD (Single Shot Detector) |
| Face Recognition | LBPH (Local Binary Patterns Histograms) |
| Pre-trained Models | Caffe format (~10MB, auto-downloaded) |
| Metric | Value |
|---|---|
| Detection Speed | ~30 FPS (modern CPU) |
| Recognition Accuracy | Good for controlled environments |
| Memory Usage | ~100MB (including models) |
Customize the system by modifying face_recognition.py:
| Parameter | Location | Default | Purpose |
|---|---|---|---|
| Detection Confidence | Line 52 | 0.5 |
Face detection threshold |
| Recognition Threshold | Line 137 | 100 |
Face match confidence |
| Face ROI Size | Line 95 | (200, 200) |
Cropped face dimensions |
We welcome contributions! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Submit a Pull Request
See CONTRIBUTING.md for more details.
This project is licensed under the MIT License.
- 🖤 OpenCV — For the incredible computer vision library
- 📦 OpenCV model zoo — For pre-trained face detection models
Made with ❤️ using OpenCV