How to detect, analyze, and compare faces with Amazon Rekognition?

Reading Time: 11 minutes

Facial recognition and comparison are the major features of modern applications like employee or customer verification applications. These kinds of applications need to automate video editing or provide secondary authentication for other applications. As a developer, facial recognition and comparison is a new challenge you will face if you are developing such kinds of applications. To solve this challenge, you could develop your own machine learning model, develop an API, and manage your own infrastructure which is expensive, requires advanced knowledge, and is time intensive. Amazon Rekognition comes to a rescue in this scenario! You can use it to detect faces in an image or video without managing the infrastructure of modeling! Sounds interesting right? Let’s explore this amazing service in this blog!

In this blog, we will discuss everything you need to know about the Amazon Rekognition service provided by AWS followed by an implementation of the different types of features thus displaying mind-blowing results with the best accuracy, and finally, walk through the Amazon CloudWatch console to view an entire graph of the success and error (if any) rates on the dashboard via filtering the different types of metrics based on the operations performed on Amazon Rekognition.

In this blog, we will cover:

  • What is Amazon Rekognition
  • Features of Amazon Rekognition
  • Common Use cases
  • Benefits
  • What can you do with Amazon Rekognition?
  • How Amazon Rekognition Works
  • Working with Images
  • Working with streaming videos
  • Working with stored video
  • Interfacing with Amazon Rekognition
  • Industries and companies using Amazon Rekognition    
  • Hands-on
  • Conclusion                                 

“Amazon’s facial recognition service is being used to scan mugshots, but it’s also used to track innocuous things like soccer balls” – CNBC

What is Amazon Rekognition?

Amazon Rekognition, lets you identify objects, people, text, scenes, and activities in images and videos, as well as detect any inappropriate content. Amazon Rekognition also provides highly accurate facial analysis and facial search capabilities that you can use to detect, analyze, and compare faces for a wide variety of user verification, people counting, and public safety use cases.

Amazon Rekognition

Features

Text Detection – Amazon Rekognition can read the skewed and distorted text in photos and videos to capture information like store names, forced narratives overlaid on media, street signs, and text on product packaging.

Face search and verification – Experience face search, allowing you to identify a person in a photo or video with accuracy and agility using your private repository of face images. Also, verify identity by analyzing a face image against images you have stored for comparison.

Celebrity Recognition – Identify popular personalities from video and image libraries to catalog footage and photos

PPE Detection – Amazon Rekognition, allows you to analyze images from your on-premises cameras at scale to automatically detect if persons in images are wearing Personal Protective Equipment (PPE) such as face covers (face masks), hand covers (gloves), and head covers (helmets) and whether the protective equipment covers the corresponding body part (nose for face covers, head for head covers, and hands for hand covers).

Content Moderation – Amazon Rekognition can detect adult and violent content in images and in stored videos and provides you with detailed labels that allow you to accurately control what you want. Examples include social and dating sites, photo-sharing platforms, blogs and forums, apps for children, eCommerce sites, entertainment, and online advertising services. 

Labels – Amazon Rekognition helps you identify thousands of objects, scenes, or any specific activity. Furthermore, with custom labels, you can extract information uniquely just for your requirements. For example, you can find your logo in social media posts, identify your products on store shelves, classify machine parts in an assembly line, distinguish healthy and infected plants, or detect animated characters in videos. 

Common Use cases

Media Recognition – Automate tasks like the detection of black frames, end credits, shot changes, and color bars. You can also reduce the time, effort, and costs associated with workflows like video ad insertion, content operations, and content production.

Workplace Safety – Amazon Rekognition, lets you analyze images from your on-premises cameras to detect if employees in images are wearing PPE such as face covers, hand covers, and head covers or not.

Content Moderation – Amazon Rekognition uses metadata to easily search your images and videos with keywords, and also helps in finding the right assets for content syndication.  

Identify products, landmarks, and brands –  Custom models can easily be trained to identify famous landmarks in a city to provide tourists with information about its history, operating hours, and ticket prices by simply taking a photo.

Enable digital identity verification – Imagine performing face verification for opted-in users by comparing a photo or selfie with an identifying document such as a driver’s license. All this can be done to facilitate automated payments and other identity verification scenarios.

Flag inappropriate content – You can create your own rules based on what is considered appropriate for the culture and demographics of your users.

Benefits

Benefits of Amazon Rekognition

What can you do with Amazon Rekognition?

What can you do with Amazon Rekognition?

How Amazon Rekognition works?

You get two API sets in Amazon Rekognition. Use Amazon Rekognition Image for analyzing images, and Amazon Rekognition Video for analyzing videos.

Amazon Rekognition Image can be used to detect real-world objects or faces in the image. After your application stores, the information returned from Amazon Rekognition Image, the user could then query their photo collection for photos with a specific object or face.

How Amazon Rekognition works?

Amazon Rekognition Video will track the path of people in a stored video. Alternatively, you can use Amazon Rekognition Video to search a streaming video for persons whose facial descriptions match the facial descriptions already stored by Amazon Rekognition. 

Working with Images

You can use the Amazon Rekognition Image API operations to analyze images stored in an Amazon S3 bucket and image bytes loaded from the local file system. Types of analysis that Amazon Rekognition Image can perform on images.

How Amazon Rekognition works?

Working with streaming videos

Amazon Rekognition Video will detect and recognize faces in streaming video. A typical use case is when you want to detect a known face in a video stream. Amazon Rekognition Video uses Amazon Kinesis Video Streams to receive and process a video stream. The analysis results are output from Amazon Rekognition Video to a Kinesis data stream and then read by your client application.

Working with stored videos

Amazon Rekognition Video is an API that you can use to analyze videos. With Amazon Rekognition Video, you can detect labels, faces, people, celebrities, and adult (suggestive and explicit) content in videos that are stored in an Amazon Simple Storage Service (Amazon S3) bucket. Moreover, Amazon Rekognition Video is categorized as media/entertainment and public safety. 

Previously, scanning videos for objects or people would have taken many hours of error-prone viewing by a human being. Amazon Rekognition Video automates the detection of items and when they occur throughout a video.

Interfacing with Amazon Rekognition

Interfacing with Amazon Rekognition

Industries and companies using Amazon Rekognition  

Industries and companies using Amazon Rekognition 

Hands-on

In this hands-on, we will see how we can make use of the different features like face comparison, facial analysis, text in images, etc. services provided by the Amazon Rekognition service. Amazon Rekognition is known for providing fast and accurate face search, identifying a person in a photo or video using your personal face images. It also provides the flexibility of verifying identity by analyzing a face image against images you have stored for comparison.

We will be implementing the following features in this hands-on:

  • Face comparison
  • Facial analysis
  • Text in image
  • Celebrity recognition
  • Object and scene detection
  • Viewing metrics on Amazon CloudWatch

Sign in to the AWS console and navigate to the Amazon Rekognition Dashboard. Click on ‘Face Comparison’ on the left navigation pane.

If you see the image below, the Amazon Rekognition service initially loads sample images and shows a face comparison result. Scroll down and select the first image by clicking on ‘upload’ under ‘Reference face’.

How to detect, analyze, and compare faces with Amazon Rekognition?

In this blog, for the reference image, we will be using the below image of ‘Andy Jassy’ (CEO of AWS).

How to detect, analyze, and compare faces with Amazon Rekognition?

After uploading the first image, it will be displayed as shown below.

How to detect, analyze, and compare faces with Amazon Rekognition?

Now, click on ‘Upload’ under ‘Comparison faces’ and select an image for the faces to be compared. In this blog, we will be using an image of some public figures of AWS in a poster as shown below.

How to detect, analyze, and compare faces with Amazon Rekognition?

After uploading the second image, you will view it as shown below. Now, on the right navigation pane, expand the ‘Results’ section.

You will view the face comparison result for the two pictures you uploaded as shown below along with the Similarity percentage. It fetches each face from the image on the right and compares the face fetched from the left side image thus providing the results as shown below.

How to detect, analyze, and compare faces with Amazon Rekognition?

To view the JSON response and the metrics that were used for comparison, expand the ‘Response’ section and you will see all the metrics as type in the response object that was used for comparing both the pictures.

If you scroll down, you will find the JSON object for each of the faces in the right image compared to the left and its respective similarity percentage values.

How to detect, analyze, and compare faces with Amazon Rekognition?

Now, click on the ‘Facial analysis’ section in the left navigation pane. Click on ‘Upload’ and select an for which you want to perform the Facial analysis.

How to detect, analyze, and compare faces with Amazon Rekognition?

In this blog, for this service, we will be using the image we used above for comparing faces. Once done, expand the ‘Results’ section to view the metrics of analysis.

If you see the image below, you will notice that under results there are metrics determined by the Amazon Rekognition service and results (in form of percentages) for the same.

How to detect, analyze, and compare faces with Amazon Rekognition?

Click on the arrow beside the first face detected and you will see the results for the next face detected in the image.

To view detailed metrics, click on ‘Show more’ and you will see all the metrics detected by the Amazon Rekognition service.

How to detect, analyze, and compare faces with Amazon Rekognition?

To view the JSON response object for detailed analysis, expand the ‘Response’ section on the left navigation pane.

Now, click on ‘Text in image’ service in the left navigation pane. When you click on the first sample image under ‘Choose a sample image’, you will see that the Rekognition service detects all the texts in an image and provides a list of them under the ‘Results’ section.

How to detect, analyze, and compare faces with Amazon Rekognition?

Click on ‘Upload’ and select an image on which you want to test this service. In this blog, we have used the same image as above.

Once uploaded, you will see all the texts detected from the image under the ‘Results’ section in the right pane on the Rekognition dashboard.

To view the JSON object and further details like the position (X and Y) coordinates of where the texts were detected, expand the ‘Response’ section in the right pane.

Now, let’s explore the ‘Celebrity recognition’ service offered by Amazon Rekognition. Click on the same in the left navigation pane.

How to detect, analyze, and compare faces with Amazon Rekognition?

Upload an image of a celebrity and Amazon Rekognition will detect the face and provide you with the name of the celebrity and its accuracy rate as shown in the image below as ‘Match confidence’.

To view the detailed metrics in the form of an object, expand the ‘Response’ section in the right pane.

How to detect, analyze, and compare faces with Amazon Rekognition?

Let’s explore another service offered by Amazon Rekognition – Object and scene detection. Click on the service in the left navigation pane and choose a sample image. On selecting the sample image, you will see all the objects detected in the image on the right side of the dashboard under the ‘Results’ section with their accuracy percentages.

Click on ‘Upload’ if you want to test out this service on any of your images. Once uploaded, expand the ‘Results’ section on the right navigation pane.

As shown in the image below, all the objects will be detected from the image and will be displayed with their accuracy percentage in the right section of the dashboard. You can click on ‘Show More’ to view all the objects detected.

To view the metrics and track the success and error rates of your entire activity for all the services you used on the Amazon Rekognition console, click on ‘Metrics’ in the left navigation pane. As shown in the image below, you will see the success and error (if any) rates in the form of graphs and the overall total calls made to the services.

Scroll down to view details/graphs for other metrics. To view the details and insights in figures, click on ‘See details on CloudWatch’ below the graph modal.

If you hover at the endpoints on the graph plotted as shown below, you will get to see the figures of the overall success calls made for ‘DetectedFaceCount’

How to detect, analyze, and compare faces with Amazon Rekognition?

Now, click on ‘All metrics’ to view figures for all the services you performed on the Amazon Rekognition console.

Now, click on ‘Operation Metrics’. You will get a list of all the operations you performed on the Amazon Rekognition console. Select the checkbox beside an operation to view the details on the graph.

Amazon CloudWatch provides different ways in which you can customize the look and feel of your graph based on your preference. On top of the graph, on the right of ‘custom’, click on the drop-down box and you will see the different types of graphs Amazon CloudWatch provides.

We selected ‘Stacked area’ and the result is as shown below for the two operations we chose under the metrics tab and performed the same on the Amazon Rekognition console.

How to detect, analyze, and compare faces with Amazon Rekognition?

Conclusion

In this blog, you have seen how to use the console to analyze and compare faces. We have explored that we can use Amazon Rekognition when needed to perform facial analysis at scale without worrying about infrastructure or training a model for identifying persons of interest, cataloging a digital library, creating a face-based employee verification system, or performing sentiment analysis. We will discuss more of AWS Rekognition and its other implementations in our upcoming blog. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies. 

Meanwhile …

Keep Exploring -> Keep Learning -> Keep Mastering

This blog is part of our effort toward building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, and build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.

Back To Top