A real-time face detection and recognition pipeline using Python and OpenCV. Collects face samples from webcam, trains an LBPH recognizer, and runs live recognition. College project (2024).
A complete face recognition system with three stages: data collection (captures and saves face crops from webcam), training (builds an LBPH model from collected faces), and live recognition (detects and identifies faces in real-time video with confidence scores).
face-recognition-opencv/
|-- src/
| |-- collect_faces.py # Capture face samples from webcam
| |-- train_model.py # Train LBPH recognizer
| |-- recognize_live.py # Real-time face recognition
| |-- face_utils.py # Shared utilities (detection, drawing)
|-- dataset/ # Face images organized by person name
|-- models/
| |-- face_recognizer.yml # Trained LBPH model
| |-- labels.txt # Label-to-name mapping
|-- tests/
| |-- test_utils.py # Unit tests
|-- docs/
| |-- how_it_works.md # Technical explanation
|-- requirements.txt
|-- .gitignore
|-- README.md
pip install -r requirements.txtpython src/collect_faces.py --name YourName --samples 50Opens webcam, detects your face, and saves 50 cropped grayscale images.
python src/train_model.pyTrains an LBPH model on all collected faces and saves it.
python src/recognize_live.pyOpens webcam and identifies faces in real-time. Shows name and confidence. Press 'q' to quit.
- Python, OpenCV (Haar Cascades + LBPH Face Recognizer)
- NumPy
Pathi Manikanta
- B.E. Computer Science & Engineering (Data Science), Anna University, 2025