Simple Face Recognition algorithm using Python and OpenCV
- Python 3.5+
- OpenCV 3.1.0
- Numpy
This project consist of 3 parts, which are:
- Creating datasets (face_datasets.py)
- Train the model (training.py)
- Face Recognition (face_recognition.py)
- Make sure have executable permission. (chmod 777 .)
- Remove the post-it note from your webcam.
Add a person
- Run
python face_datasets.pyto add images. Two directories 'datasets' and 'trainer' will be created in the project directory. 'dataset' should populate with the images. - Train your datasets by running
python training.py. - Lastly, run
python face_recognition.py
Add additional people
- Change the variable "face_id = 1" to "face_id = 2" in (face_datasets.py: line 23) and re-run
python face_datasets.py python training.pypython face_recognition.py- You can change the 'Id' to match user's name (face_recognition: line 62):
ex).if (Id == 1): Id = "User1"toif (Id == 1): Id = "Bill"
if you get an error try:
-
pip install opencv-contrib-python -
pip install opencv-python -
Depending on how python is configured on your machine, you may need to use
python3andpip3instead ofpythonandpipwhen running the scripts
Anirban from TheCodacus. Link: http://thecodacus.com/ All rights reserved to the respective owner
