The phenomenon that makes machines such as computers or mobile phones see the surroundings is known as Computer Vision. It is a field of Computer Science that focuses on replicating parts of the complexity of the human vision system and enabling computers to identify and process objects in images and videos in the same way that humans do.

Some applications of Computer Vision includes:

  • Object detection
  • Face Detection
  • Face Recognition
  • Self Driving cars
  • Autonomous Drones

Face Detection is not perfect but it has reached stages where it is accepted in our daily lives from unlocking the phone to sending money.

The Viola-Jones Algorithm

This algorithm is the foundation of the OpenCV library. It was developed by Paul Viola and Michael Jones in 2001. It allows the detection of images in real-time.

How it works

There are two stages in this algorithm

  1. Training
  2. Detection

We’ll discuss Detection first

Detection

This algorithm is designed to look for **Frontal Faces. **The performance will be poor when it comes to detecting side-ways, upwards, or downwards. The image is first converted into grayscale because it is easier to work and takes lesser data to process. This algorithm first finds the face on grayscale images then it finds the face location in the color image.

It outlines a rectangular box and searches for a face from the top-right corner left. It looks for haar like features which we will be discussed later in this blog. The rectangular box right side after every step on the tile.

Photo by mahdis mousavi on Unsplash

Haar-like Features

It is named after Alfred Harr, a Hungarian mathematician who developed the concept of Haar wavelets. The features below show a box with a light side and a dark side, which is how the machine determines what the feature is.

There are three types of Haar Features that Viola and Jones discovered, they are

  1. Edge Features
  2. Line Features
  3. Four Rectangle Features/ Four-sided features

Edge Features

For example, you want to detect eyebrows., the shade of the pixels on an eyebrow in an image will be darker and abruptly gets lighter (skin). Edge features are great for finding this.

Edge Features

Line Features

Naturally, the region of your lips on the face goes from light to dark and again light. This feature is best to find

Line Feature

Four side Features

four rectangle feature

These features help the machine understand what the image is. when the images are inspected, each feature has a value of its own. It’s quite easy to calculate: Subtract White area from the Black area

Integral Images

Calculating the value of a feature would be really complex as the number of pixels increases i.e in a larger image. The Integral Image concept helps to perform intensive calculations quickly so we can understand whether a feature of a number of features fit the criteria or not.

Let us explore a bit by explaining how it works. Consider the below image

Each point in the integral image is a sum of the pixels above and left of the corresponding pixel in the source image. We use this because instead of doing additions for every pixel values for all features we use this to make use of a few subtractions to get the same result.

#programming #deeplearing #algorithms

The Viola-Jones Algorithm
1.35 GEEK