A lightweight and practical face-recognition system combining:
- MediaPipe Face Mesh for face detection
- OpenCV LBPH for classical face recognition
This project provides a complete workflow: capture → train → recognize.
project/ │── capture.py # Capture and store face images │── train.py # Train the LBPH model │── predict.py # Real-time face recognition │── dataset/ # Auto-created user image folders │── models/ │ ├── lbph_model.xml │ └── label_map.json │── README.md
Run:
python capture.py
You will be asked to enter your name. Look into the camera and press Q to stop.
Images are saved in:
dataset/<your_name>/
Run:
python train.py
This generates:
models/lbph_model.xml models/label_map.json
Run:
python predict.py
The webcam window will display:
- A green rectangle around the face
- The predicted name
- The LBPH confidence score
Press Q to exit.
pip install opencv-python mediapipe pip install opencv-contrib-python
git clone https://github.com/amani-patrick/Facial_recognition.git
cd Facial_recognition
python -m pip install mediapipe opencv-python
Then run:
- python capture.py
- python train.py
- python predict.py
- Works with any number of people.
- For each new user, repeat capture → train.