Face-Recognition Using OpenCV: A step-by-step guide to build a facial recognition system

Naveen Manwani
HackerNoon.com
5 min readOct 23, 2018

--

Whenever you hear the term Face Recognition, you instantly think of surveillance in videos, and would could ever forget the famous Opening narration “ You are being watched. The government has a secret system, a machine that spies on you every hour of every day. I know because I built it” from Season One of the television show person of interest .I still get goosebumps whenever I hear it.

First thing first

Literature:

Over the last ten years or so, face recognition has become a popular area of research in computer vision and one of the most successful applications of image analysis and understanding. Because of the nature of the problem, not only computer science researchers are interested in it, but neuroscientists and psychologists also. It is the general opinion that advances in computer vision research will provide useful insights to neuroscientists and psychologists into how human brain works, and vice versa.

Face Recognition systems use computer algorithms to pick out specific, distinctive details about a person’s face. These details, such as distance between the eyes or shape of the chin, are then converted into a mathematical representation and compared to data on other faces collected in a face recognition database. The data about a particular face is often called a face template and is distinct from a photograph because it’s designed to only include certain details that can be used to distinguish one face from another.

Source: https://thefwa.com/cases/ava-sessions-t64

After explaining you in brief about what is face recognition and how it works it’s time to clear my intentions with regards to this article . In this article I’ll introduce you with very simple easy to follow python code to build a Face Recognition system that will run on a video of any person of your choice.

So, without stalling further let’s deep dive in, and I assure you by the end of this article you’ll be able to make your own face recognition over video pretty smoothly.

Installation

Requirements

  • Python 3.3+ or Python 2.7
  • macOS or Linux (Windows not officially supported, but might work)
  • OpenCV

Installation Options:

Installing on Mac or Linux

First, make sure you have dlib already installed with Python bindings:

Then, install this module from pypi using pip3 (or pip2 for Python 2):

If you are having trouble with installation, you can also try out a pre-configured VM.

After installing all the dependency it’s time to get your hands dirty, which means to write the code which will make bring your Face Recognition system into existence.

The images I used are:

Bollywood Actress and Actor : Warina Hussain and Aayush sharma

And that’s it , it’s done if you follow along exactly the way it’s been shown here then you all too will achieve what I achieved.

The demo for the Face Recognition system which I built can be seen below.

info:do see it in full-screen

Special Mention: This article would have been impossible without the direction given by Adam Geitgey through his famous face recognition github repository which you can check it here.

REFERENCES:

  1. The GitHub repo can be found here.
  2. In order to know more about Face Recognition click here.
  3. In order to know more about the library dlib click here.
  4. In order to know more about OpenCV click here.

Thank you for your attention

You using your time to read my work means the world to me. I fully mean that.

If you liked this story, go crazy with the applaud( 👏) button! It will help other people to find my work.

Also, follow me on Medium, LinkedIn or Twitter if you want to! I would love that.

--

--

Naveen Manwani
HackerNoon.com

Electronics Engineer by degree, ML engineer by interest, Hardware tinkerer by choice