O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing SSD face detection into OpenCV

To work with deep learning in our code, we have to import the corresponding headers:

#include <opencv2/dnn.hpp>#include <opencv2/imgproc.hpp>#include <opencv2/highgui.hpp>

After that, we will import the required namespaces:

using namespace cv;using namespace std;using namespace cv::dnn;

Now we are going to define the input image size and constant that we are going to use in our code:

const size_t inWidth = 300;const size_t inHeight = 300;const double inScaleFactor = 1.0;const Scalar meanVal(104.0, 177.0, 123.0);

In this example, we need a few parameters as input, such as the model configuration and pre-trained model, if we are going to process camera or video input. We also need the minimum confidence ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required