Facial recognition (or face recognition) systems are commonly used for security purposes. Today, this technique finds its application in a broad range of industries including retail, event management, hospitals, academies, defense wings, government departments, commercial establishments, banks, and financial institutions. Facial recognition is a biometric method of identifying (recognizing) an individual by comparing live capture or digital image data against the stored record for that person. Before we move on, let us have a quick glance at the two terms- face detection and face recognition.

Face Detection and Recognition – An Overview

Face Detection and Face Recognition are two distinct concepts that differ completely from each other, though recognition builds upon detection. In Detection, the system identifies human faces in digital images, irrespective of the source of the image. In Recognition, the system recognizes a known face in a digital image with a known name. Here also, source is not a matter of concern. Source could be any of these: a scanned photograph, a live video stream or a CCTV footage.

Incorporating face detection and recognition technologies in businesses allows you to generate vast amounts of useful data, that can be further analyzed to derive advanced insights and business intelligence. Face recognition-powered analytics solution plays a significant role in many industries, since it reduces the gap between business and customer.

Currently, numerous open source codes are available in the market for face detection and recognition, out of which, the most widely used solutions are OpenFace, OpenCV using EMGU .NET Wrapper, and MS Azure Face API. In this post, we will have a look at how Microsoft Azure Face API helps in face detection and recognition.

Microsoft Azure Face API

Microsoft Azure Face API offers advanced algorithms that detect human faces in digital images. Face API can detect one or more human faces in an image and display face rectangles to highlight the faces in the image. Along with this, Face API also shows attributes that include machine-learning based predictions of facial features. The attributes comprise age, gender, emotion, pose, smile and facial hair, in addition to 27 other landmarks for each face identified in the given image. State-of-the-art algorithms detect human faces in images, opening a range of facial capabilities to your applications.

Microsoft Azure Face API can:

  • Detect human faces and search for similarities
  • Consolidate images into groups based on their visual similarities
  • Identify any previously tagged people in images

Once Face API identifies the faces, it will verify to find out whether two people in an image or images are the same by using a confidence score, or compare it against a database to find out whether an identical face already exists. Face API uses the shared visual traits to group similar looking faces.

MS Azure Emotion API

Emotion API provides you an incredible personalized experience by allowing you to build an application that recognizes emotions from facial expressions. This is a cloud-based API that detects emotions such as happiness, sadness, neutrality, contempt, anger, disgust, fear, and surprise. Emotion API analyzes these emotions based on universal standards of categorizing facial expressions. It functions in a cross-cultural manner. That means, your application will work across the globe.

Subscription and Implementation

Users with a Microsoft Azure subscription can implement Face API, since it is a paid service. You can create your own Face API service using the Azure portal. This helps your application to perform face detection and recognition.

 

Quick steps to implement Microsoft Azure Face API

The following example is based on Windows OS and source code is purely in C#. To implement these steps, you need to have a Microsoft Azure subscription.

Step 1:

Create Face API service in MS Azure as displayed below:

Screen shot of Microsoft Azure Face API Service

Step 2:

Go to “All Services” menu, where you can see your services listed. Note the subscription id, end point, and access keys which we need later in our program.

Screenshot of Microsoft Azure Face API All Services Menu

Step 3:

Select the appropriate price tier for creating the service. In this example, we are using the “Free Price Tier” for demo purpose.

Step 4:

Different stages of Face recognition and Detection

  • Authorize API call: While using face API client services, you should authorize yourself for a valid subscription key.
private FaceServiceClient _faceClient = new FaceServiceClient("Your subscription key");

 

  • Create person group: Person group acts as a container of all persons. In the following code snippet, replace personGroupId with your group name as per your requirement (example: mygroup, group1).

Screenshot of Person Group creation

  • Add person to group: Here we are adding persons to previously created group.
 // Define Person
CreatePersonResult friend1 = await _faceClient.CreatePersonAsync(“Give the previously created group name”, “Give unique person name”);

 

  • Add person’s faces (Take Training images)

Screenshot of the code to capture training images

  • Train person group: The person group must be trained prior to performing an identification using it. Moreover, it has to be re-trained after adding or removing any person, or if any person has their registered face edited.

Screenshot of code for training person group

  • Identify Person: The following code demonstrates the process of identification.

Screenshot of code for identifying a person

The result will appear as shown below:

Capture 1: Same gender group with different emotions.

Screenshot of face detection and recognition.

Capture 2: Different genders and emotions

Face recognition screenshot 2

 

The Microsoft Azure Cognitive Service Face API Application helps you to make a Face API app in 30 minutes. All you need is a Microsoft Azure subscription. Azure Face API has an accuracy of 90-95%.

Posted by Arun Antony

Arun Antony is a Senior Software Engineer at Zerone Consulting. Arun is a passionate technology enthusiast who loves to explore and write about Natural Language Processing (NLP) technologies and Rest API integrations. He is also proficient at Microsoft .NET technologies.

2 Comments

  1. Arun, can you give a link where I can find “official” Microsoft numbers regarding Face Api accuracy? ( False Positive )

    Reply

    1. We don’t have an “Official” reference to share with you regarding the Face API accuracy. If you are looking for the relevancy of our acquired accuracy (90-95%), it is completely based on our past experiences with Azure Face API. We have tried different data sets for training images which includes male and female personas as depicted in our blog. One factor that affects the results from Azure is the “Confidence Threshold” value. We can specify the threshold value in our code along with “IdentifyAsync” function. It’s a decimal value ranges from 0 to 1. In our application we gave threshold value as “0.7f” which again was finalized after various tests. Hope this helps.. Thanks!

      Reply

Leave a Reply