After a lot of theory, we finally arrive at a point where we are now ready to do face detection using OpenCV. As always, we will straightaway dive into code.
First, we include the required header files. Here, you'll note the appearance of a new header--objdetect.hpp
. This file contains all the function declarations that we'll use for our face detection:
#include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/imgproc/imgproc.hpp> using namespace std; using namespace cv;
Here, we declare the path to what we call the cascade classifier. Let us take a moment to understand what this file contains and why we need it in our code. During our explanation of the Viola-Jones framework, we saw that given some Haar features computed from within the sub-window, a classifier (arranged within a cascade) must...