Understanding Face Detection from scratch

Daniel Baquero
7 min readDec 18, 2020

First of all I’d like to briefly introduce myself. I’m an American and a Colombian. I’m a full-stack engineer currently specializing in augmented and virtual reality, two types of tech which I’m very passionate about. I learned most of my software engineering skills through a project-based, peer learning curriculum, which enriched as well my soft skills. I’m open to new challenges every day !

The goal of this article is to explain Face Detection as if you were a non-technical person, so expect concepts that are usually understood by the majority of the people. The blog will be addressing the following:

· What is face detection

· How face detection works

· Advantages and disadvantages of face detection

· What practical applications it could have

Having that said, let’s commence having some fun with this interesting technology!

What is face detection?

Face detection is a kind of technology that is powered by a computer or technological intelligence used to detect and identify human faces in digital images. In even more simpler terms, face detection is the process of a technological device of identifying through a series of smaller processes if the image that is receiving through the camera is a face or not; it’s really has simple as that, detecting through the camera of your device if what it’s seeing is a face or not.

Face detection is used in various fields nowadays, including security, biometrics, law enforcement, entertainment and personal safety. It’s mainly used to provide surveillance and tracking of people in real-time.

This technology has been evolving from rudimentary computer vision techniques to advances in machine learning to increasingly sophisticated artificial neural networks, as you can see it has had incredible improvements since it was first introduced. If you were asking yourself what machine learning was, it’s according to the tech giant, IBM — “Machine learning is a branch of artificial intelligence (AI) focused on building applications that learn from data and improve their accuracy over time without being programmed to do so.” https://ibm.com/cloud/learn/machine-learning.

In things like face analysis, face detection helps identify certain aspects of a human like age, gender and emotions. In a facial recognition system, the facial features are stored in numbers and this data is used as a faceprint. Now that we understood what exactly a facial detection was, let’s review how it works.

How does face detection work ?

Before getting into the functionality of face detection let’s review an important concept first. Let’s understand what an algorithm is. According to the website of BBC, “An algorithm is a list of rules to follow in order to solve a problem.” — https://www.bbc.co.uk/bitesize/topics/z3tbwmn/articles/z3whpv4. This is as simple as it gets, but now we need to know what it exactly is in computing terms. An algorithm in computing, provides computers with a continuous guide to completing actions. It’s a precise list of orders given to a computer in order to perform a desired action.

Now we can really dive in how face detection works. So, face detection uses algorithms and machine learning to find faces compared with larger images, which usually are mixed up with other non-face real-world elements at the background like walls, televisions, building, landscapes, etc.

The first sub-process that takes place is searching for the humans eyes, which is one of the most distinctive feature and one of the most easiest ones to identify. That’s why it’s the first thing it looks for because if it doesn’t have human eyes, it probably isn’t a face and it returns as a message a fail statement in your phone or image or video your testing. The algorithm might follow with a with the attempt of searching and trying to identify if there is eyebrows, a mouth, nose, nostrils and an iris. Once the algorithm identifies all of these facial features and some additional testing, it probably concludes that it’s a human face.

But how is accuracy ensured in these tests ? Well, think of the following example. Let’s say that you just understanding what a chair is, the first time you see one you wouldn’t know that what you’re seeing is a chair, but then your parents or someone tells you that it’s a chair. The chair that you saw is an armless one. You may have an unclear concept of what exactly a chair is but you have some sort of understanding. The next day you saw another chair but without arms, you could ask yourself if that object is still considered a chair and get to the right answer by yourself or ask someone. You have increased your knowledge on chairs and understand that there may be different types. The next day you see a sofa and might think that it’s a chair since it’s an object where you could sit comfortably and is something designed in order for someone to sit but when you ask someone if it is a chair, the person tells you that it isn’t and that it is a sofa. You now have more information regarding what is and isn’t a chair and can distinguish them in a more accurate way.

This is how computer algorithms and computer intelligence works. The algorithms need to be trained on large sets of data or information incorporating hundreds of thousands of positive and negative images. The sort of training that the algorithms have is essential to have the ability to determine whether there are faces in an image and where they are.

The methods used in face detection can be:

· knowledge-based

· feature-based

· template matching

· appearance-based

Each one of them have their advantages and disadvantages. Check out each one of them for further understanding on the topic.

Although there are a lot of algorithms that have a good probability of detecting human faces, detecting faces in pictures can be complicated due to the variability of factors such as pose, expression, position and orientation, skin color and pixel values, the presence of glasses or facial hair, and differences in camera gain, lighting conditions and image resolution. The good thing is that there’s something called “deep learning” that improved and made the concept of face detection have a huge evolution. What is deep learning ? You may ask. According to the website of Machine Learning Mastery, “Deep Learning is a subfield of machine learning concerned with algorithms inspired by the structure and function of the brain called artificial neural networks.” — https://machinelearningmastery.com/what-is-deep-learning/.

Nowadays one of the most popular frameworks of face detection is the one presented by the researchers Paul Viola and Michael Jones. Although their framework is one of the most used for recognizing face in real-time applications, it has limitations. Things like having a mask or scarf on, would affect the process that the algorithm goes through and possibly would return that it isn’t a face. But no worries, there are other algorithms that’ll help you out in these situations, these are: the region-based convolutional neural network (R-CNN) and Single Shot Detector (SSD).

Advantages and disadvantages

Some of the advantages of facial detection are:

· Improves security. This technology helps surveillance services and identifies criminals and terrorists in real-time. The data stored as faceprints are safe since there are no passwords or sensible data that can be hacked for their personal dispense.

· Easy to implement. Face detection and facial recognition technology are easy to use in your projects, they are found in some sort of library where you can make use of these technology and develop your own project powered with these libraries.

· Easy and automated identification. Before this kind of technology, the process of identifying a person was done manually and took a considerably long time. Face detection allows this process to be automated, which reflects in efficiency and accuracy.

Some of the disadvantages are:

· Massive data storage burden. In order to make use of this technology, you will need a massive data storage that may not be available for all of the users.

· Vulnerability in detection. Although the face detection algorithm may be precise, when aspects like camera angles and appearance are modified it may affect the result.

Potential breach of privacy. Although the ability of detecting faces of criminals and terrorists in real-time may be beneficial, the same surveillance is used with private citizens, which may be a breach of their privacy. Strict regulations must be set to ensure the technology is used fairly and in compliance with human privacy rights.

What practical applications does it have ?

As we said before, surveillance purposes are one of the most common practical applications of face detection. Face detection can also be used to auto-focus cameras which can help identify how many people are present in a certain area. Another application, which is very interesting and awesome in my opinion is to help people with autism understand the feelings around them through a software of emotional inference.

This blog was made for educational purposes for Holberton School, a project-based, peer learning full stack software engineering school located in: United States, Colombia, France, Lebanon, Mexico, Puerto Rico, Tunisia and Uruguay. Thank you for reading this blog and I hope I helped you out understanding this abstract topic.

--

--