This device is not compatible.


Face Detection Using Dlib and DNN in OpenCV

Face detection is a computer vision task that allows a program to detect a human face in a photo or video. Face detection can help embellish selfies and portraits or produce virtual avatars from a user's photo. In this project, we’ll learn to detect the faces in a photo using dlib and DNN in OpenCV.

Face Detection Using Dlib and DNN in OpenCV

You will learn to:

Display images using Python

Use Resnet10-SDD-300x300 in OpenCV

Use HOG-based face detector from dlib

Detect and plot face boundaries in an image


Data Visualization

Data Manipulation

Machine Learning Fundamentals


Basic understanding of Python

Basic understanding of data analysis

Basic understanding of data visualization




Project Description

Face detection is one of the most fundamental aspects of computer vision.

We’ll use:

Frontal face detector dlib: Dlib is a C++ toolbox for employing machine learning techniques to solve real-world problems. Despite being built in C++, it includes Python bindings executed in Python. The dlib frontal face detector extracts feature using Histogram of Oriented Gradients (HOG) and then processes using an SVM.

Caffe model with DNN from OpenCV: The Caffe model is based on the Single Shot-Multibox Detector (SSD) that uses the ResNet-10 architecture. It was added to OpenCV’s deep neural network module after version 3.3.

After we have worked with both, we’ll compare them to see which one performs better for different examples. Let’s get started!

Project Tasks



Task 1: Import Necessary Libraries

Task 2: Download and Visualize the Image


Face Detection Using resnet

Task 3: Load the DNN Network

Task 4: Prepare the Image for the Network

Task 5: Running the Network

Task 6: Label and Visualize the Image


Testing Your Solution

Task 7: Getting Model Results

Task 8: Performance Test


Face Detection Using dlib

Task 9: Convert the Image to Grayscale

Task 10: Run the Detector Using Dlib

Task 11: Label the Image and Visualize the Result


Testing Your Solution

Task 12: Getting Model Results

Task 13: Performance Test