Detect faces using OpenCV's deep neural network module.
- OpenCV 3.3+
- Python
There are lots of different ways on how to install OpenCV and it's Python module.
The easiest way would be to install it through the unofficial Python package using Pip.
You can also compile OpenCV on your machine yourself, there are many tutorials covering this topic already.
For OSX you can e.g. try out this tutorial.
In addition to OpenCV, you'll also need a network model. While you're able to train your own, you can also use pre-trained models.
The pre-trained model in this repository consists of following files:
- deploy.prototxt - The
.prototxt
file with text description of the network architecture - res10_300x300_ssd_iter_140000.caffemodel - The pre-trained face detector DNN model
Simply run php index.php
, your images with face detection will be saved in /dataset-output/opencv-deep-learning
.
The PHP script uses by default the python
command line program.
If you want to use another command line program (e.g. python3
),
simply run composer install
and copy the .env.example
file to .env
and customize the command line program.