A Flask-based real-time face recognition web application that allows users to register their faces and identify previously registered users using OpenCV's Haar Cascade face detector and LBPH Face Recognizer.
- 📷 Live webcam feed
- 👤 Register new users with face capture
- 🧠 Train an LBPH face recognition model
- 🔍 Recognize registered users in real time
- 🎨 Modern cyberpunk-inspired web interface
- ⚡ Built with Flask and OpenCV
- Python
- Flask
- OpenCV
- OpenCV Contrib (LBPH Face Recognizer)
- NumPy
- HTML/CSS/JavaScript
face-recognition/
│── app.py
│── face_model.py
│── requirements.txt
│── .gitignore
│
├── templates/
│ └── index.html
│
├── static/
│ ├── style.css
│ └── script.js
│
├── dataset/ # Generated face images (ignored)
├── trainer.yml # Trained LBPH model (ignored)
└── labels.npy # User labels (ignored)
git clone https://github.com/navya2006/face-recognition.git
cd face-recognitionpython3 -m venv venvActivate it:
macOS/Linux
source venv/bin/activateWindows
venv\Scripts\activatepip install -r requirements.txtpython app.pyOpen your browser and visit:
http://127.0.0.1:5000
- Enter your Name
- Enter a unique User ID
- Click Capture & Train
- The application captures your face and trains the recognition model.
- Stand in front of the camera.
- Click Identify Face.
- The system predicts the registered person's identity.
- Python 3.10+ (recommended)
- Webcam
- OpenCV Contrib
Install dependencies with:
pip install -r requirements.txt- The
dataset/,trainer.yml, andlabels.npyfiles are generated after registering users and are excluded from version control. - If the webcam does not appear, ensure camera permissions are enabled for your terminal or IDE.
- If you encounter issues with Haar Cascade files, use a stable version of
opencv-contrib-python(e.g.4.10.0.84).