How to do it...

Using deep learning in OpenCV is very easy, and the only files that we require are the pre-trained models and know the basic configuration of it. We can download tested, pre-trained OpenCV models from https://github.com/opencv/open_model_zoo.

To create the face detector algorithm, follow these steps:

  1. Download and save the model of the face detector in the data folder (for convenience, we downloaded the required models and saved them in the data folder). It requires two files normally: the weights and the network structure. In our case, we are going to download the deploy.prototxt file, which defines the structure of the network, and res10_300x300_ssd_iter_140000.caffemodel, which contains the weights of the network.
  2. Let's ...

Get OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.