You can use this project by cloning the repository with Git command:
git clone https://github.com/anhnguyenphung/face_detection
Then move to the directory that you just have cloned by running the following command in the terminal:
cd face_detection
To detect faces in a picture, run the following command in the terminal:
python face_detection.py image_file
where image_file
is the location of the image file (in JPG or PNG format) that you want to detect faces. There are some example pictures in the folder
example_pictures
of the repository, or you can choose your own pictures, to test out.
For example, python face_detection.py example_pictures/example_1.jpg
would produce the following output:
python face_detection.py example_pictures/example_2.jpg
would produce the following output:
To detect faces in webcam, run the following command in the terminal:
python webcam_face_detection.py
For example, when I ran the above command on my terminal, I had the following output:
From this project, I have learned how to use OpenCV library in Python for face detection, thanks to blog posts from Real Python.