Python: Implement Face Detection Using dlib

In this tutorial, we will introduce how to implement face detection using python dlib.

Python - Implement Face Detection Using dlib - A Step Guide

We also can use python opencv to detect faces in an image, here is the tutorial:

Detect Number of Faces in an Image Using OpenCV in Python

1.Install dlib

pip install dlib

2.Read an image using dlib

img = dlib.load_rgb_image("Test.jpg")

3.Create a window to show image

win = dlib.image_window(img)

4.Create a detector to detect face in image

detector = dlib.get_frontal_face_detector()
face = detector(img)

5.Display detected faces

win.add_overlay(face)

win.wait_until_closed()

Run this code, you may see a face:

Python: Implement Face Detection Using dlib