Screen.Recording.2024-07-12.135557.-.Face.Detection.-.Copy.1.1.mp4
This is a Python-based face recognition system that allows you to train a classifier on a dataset of faces, generate a dataset of face images, and detect faces in real-time using a webcam.
- Python 3.x
- OpenCV
- Pillow
- NumPy
- mysql-connector-python
-
Clone the repository or download the code files.
-
Install the required dependencies using pip:
pip install opencv-python pillow numpy mysql-connector-python
- Make sure you have a MySQL database set up with the necessary table structure. Update the database connection details in the code accordingly.
-
Run the
face_recognition_system.py
script. -
The GUI will appear with three buttons: "Training", "Detect the face", and "Generate dataset".
-
To train the classifier, click the "Training" button. This will train the classifier on the face images in the
data
directory and save the trained model toclassifier.xml
. -
To generate a dataset of face images, fill in the name, age, and address fields, then click the "Generate dataset" button. This will capture 200 face images using the webcam and save them to the
data
directory with the user's ID. -
To detect faces in real-time, click the "Detect the face" button. This will open a window showing the webcam feed with detected faces labeled.
If you find any issues or have suggestions for improvements, feel free to create a new issue or submit a pull request.