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. Face 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.
Create Face API service in MS Azure as displayed below:
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.
Select the appropriate price tier for creating the service. In this example, we are using the “Free Price Tier” for demo purpose.
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).
- 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)
- 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.
- Identify Person: The following code demonstrates the process of identification.
The result will appear as shown below:
- Capture 1: Same gender group with different emotions.
- Capture 2: Different genders and emotions
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%.