A robust yet beginner-friendly Face Recognition System that combines computer vision capabilities with a simple graphical interface. Built using OpenCV's LBPH (Local Binary Pattern Histogram) algorithm, this system allows users to capture facial data, train recognition models, and perform real-time identification through an intuitive Tkinter-based application.
- Direct face capture via webcam with automatic detection
- Organized storage in person-specific directories
- Configurable sample count and capture interval
- Implementation of OpenCV's LBPH Face Recognizer
- Local pattern extraction for efficient recognition
- Confidence-based identification threshold
- Live webcam face detection and recognition
- Real-time confidence score display
- Frame-by-frame processing with performance optimization
- Intuitive Tkinter GUI with clear navigation
- Progress indicators for training and recognition
- Support for multiple user profiles
- Clean project structure with modular components
Face_Recognition/
โ
โโโ cli_based/
โ โโโ collect_images.py # Capture images for each person
โ โโโ train_&_recognize.py # Train model & recognize via command line
โ
โโโ face_recognition.py # Tkinter GUI + Face recognition
โโโ requirements.txt # Dependencies
โโโ .gitignore
โโโ README.md
| Component | Technology | Purpose |
|---|---|---|
| Core Language | Python 3.8+ | Application development |
| Computer Vision | OpenCV 4.x | Face detection & recognition |
| ML Algorithm | LBPH | Face pattern recognition |
| GUI Framework | Tkinter | User interface |
| Face Detection | Haar Cascades | Initial face localization |
| Image Processing | PIL/Pillow | Image manipulation |
| Data Handling | NumPy | Numerical operations |
- Python 3.8 or higher
- Webcam/camera device
- 2GB+ RAM recommended
- Clone Repository
git clone https://github.com/MuhammadUsman-Khan/Face-Recognition.git
cd Face-Recognition- Create Virtual Environment
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate- Install Dependencies
pip install opencv-python opencv-contrib-python numpy pillowpython app.py- Click "Capture Faces" in GUI
- Enter person's name
- Position face within camera frame
- System captures samples on pressing 'c'
- Images saved to
dataset/<person_name>/
- Click "Train Model" button
- System processes all images in dataset
- Progress bar shows training status
- Model saved as
models/lbph_model.yml
- Click "Start Recognition"
- Webcam activates with real-time detection
- Recognized faces show name and confidence
- Press 'q' to exit recognition mode
Webcam Frame โ Grayscale Conversion โ
Haar Cascade Detection โ Face ROI Extraction โ
Image Preprocessing โ Output
- Local Binary Patterns: Extracts texture features
- Histogram Creation: Spatial face representation
- Pattern Matching: Compares new faces with trained patterns
- Confidence Scoring: Measures recognition certainty
# Customizable settings
CONFIDENCE_THRESHOLD = 70 # Minimum confidence for recognition
IMAGE_SIZE = (200, 200) # Standardized face image size
MIN_FACE_SIZE = (30, 30) # Minimum detectable face size| Metric | Value | Description |
|---|---|---|
| Accuracy | 92-97% | Varies with lighting conditions |
| Processing Speed | 15-30 FPS | Depends on hardware |
| Training Time | ~2 sec/100 images | CPU-based training |
| Memory Usage | 150-300 MB | During recognition |
| Issue | Solution |
|---|---|
| Webcam not detected | Check permissions, try different camera index |
| Low accuracy | Increase training samples, improve lighting |
| Slow performance | Reduce frame size, close background apps |
| Memory error | Reduce dataset size, increase RAM |
- Enhanced GUI with modern design
- Multi-threading for better performance
- Export recognition logs to CSV
- Batch image processing
- Deep Learning integration (FaceNet/Dlib)
- Database support for user management
- Attendance system with time tracking
- Web-based deployment
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
- OpenCV community for excellent computer vision tools
- Tkinter documentation and community support
- All contributors and testers
- Developer: Muhammad Usman Khan
- GitHub: @MuhammadUsman-Khan