Path: blob/master/FaceDetectionComparison/README.md
3118 views
There are 10 code files in this repo - 5 for C++ and 5 for Python:
face_detection_opencv_haar.cpp and face_detection_opencv_haar.py - For Haar based face detection
face_detection_opencv_dnn.cpp and face_detection_opencv_dnn.py - For OpenCV DNN based face detection
face_detection_dlib_hog.cpp and face_detection_dlib_hog.py - for dlib hog based face detection
face_detection_dlib_mmod.cpp and face_detection_dlib_mmod.py - for dlib mmod based face detection
run-all.cpp and run-all.py - for running all the 4 together
First of all Unzip the dlib.zip file
For C++
Compile
Add path to the properly build OpenCV with DNN GPU Support and your CUDA:
For Python
Note: Our code is tested using Python 3.7.5, but it should also work with any other python3.x.
Install virtualenv:
Create new virtual environment env
and activate it:
Install numpy:
Install dlib:
Create symlink to the properly build OpenCV with DNN GPU Support:
Run
If you don't pass any filename, it will use the web cam
For individual face detectors
C++
Note: for face_detection_opencv_dnn.cpp
you can pass up to 3 arguments:
video filename, if you'd like to run inference on a video instead of a camera:
device, if you want to use CPU instead of CPU:
framework to specify Caffe (caffe) or TensorFlow (tf) network to use. Caffe network is set by default:
Python
Note: for face_detection_opencv_dnn.py
you can pass up to 3 arguments:
filename, if you'd like to run inference on a video instead of a camera:
device, if you want to use CPU instead of GPU:
framework to specify Caffe (caffe) or TensorFlow (tf) network to use. Caffe network is set by default:
For running all together
C++ ./run-all
Python python run-all.py --video
AI Courses by OpenCV
Want to become an expert in AI? AI Courses by OpenCV is a great place to start.