This project implements a facial recognition system using OpenCV and SQLite. It includes three main components: face registration, model training, and face recognition. The system captures face images, stores user information in a SQLite database, trains a face recognizer, and then uses the trained model to recognize faces in real-time.
-
register.py:
- Captures face images from the webcam and saves them to the
dataSet
directory. - Stores user information in an SQLite database (
test.db
). - Ensures that each user has multiple face images for better training.
- Captures face images from the webcam and saves them to the
-
trainner.py:
- Reads face images from the
dataSet
directory. - Trains the LBPH (Local Binary Patterns Histogram) face recognizer.
- Saves the trained model to
trainer/trainer.yml
.
- Reads face images from the
-
facerec.py:
- Loads the trained face recognizer model.
- Performs real-time face recognition using the webcam.
- Displays the recognized user's ID and name on the video feed.
-
Install Dependencies: Install the required Python packages using
pip
:pip install -r requirements.txt
-
Download Haar Cascade: Make sure you have the Haar Cascade XML file (haarcascade_frontalface_default.xml). You can download it from the OpenCV GitHub repository.
-
Run Registration: Execute register.py to capture face images and store user information:
python register.py
-
Train the Model: Run trainner.py to train the face recognizer model:
python trainner.py
-
Run Face Recognition: Start facerec.py to perform real-time face recognition:
python facerec.py
- No Faces Detected: Ensure the face images are clear and properly lit. Adjust the detectMultiScale parameters in trainner.py and facerec.py if necessary.
- Model Not Saving: Verify that the trainer directory exists and has write permissions.
@Copyright 2020 | Veendy