Detect Faces in Live Video

Introduction Face detection is the ability to detect and locate human faces in an image or a video. In the earlier post, we saw how to create an application to detect faces in an image. In this post, we will learn how to detect faces in live video.

Face Detection Algorithms The face detection algorithms for image and video work in a similar fashion. A video is actually a combination of many images or simply called frames. The face detection algorithms process each frame of the video to detect faces. The algorithms detect a face in a small window sliding across the larger frame instead of looking at the entire frame at once. When a face is detected, we will record the location of the face and move to another spot. This is called a sliding window classifier. There are several other classification algorithms use to detect the faces.

1- Viola-Jones Paul Viola and Michael Jones presented their algorithm in the early 2000s which uses ‘Decision Tree’, a machine learning algorithm. This algorithm sees the dark and light regions in an image to detect a pattern consistent with a face. The advantage is that it can run on low powered processors and which made it possible to build face detection into early cameras. On the other hand, it is not a very accurate algorithm as compare to others.

2- Histogram of Oriented Gradients (HOG) algorithm HOG, invented in 2005, looks for patterns and how fast and in what directions images shift from light to dark colors.

3- Convolutional Neural Network(CNN) CNN is the deep learning approach to detect faces and it is very accurate among all algorithms but requires a lot of training data to train the face detection neural network. Secondly, it requires high-performance computing systems to train the models.

Build an Application for Face Detection We will use face_recognition model build using ‘dlib’ library for our application. ‘dlib’ is principally a C++ library, however, we can use a number of its tools for python applications. face_recognition is a deep learning model with accuracy of 99.38%.