Create a Microsoft Azure Cognitive Service FaceAPI Application in Half an Hour

Azure Face API

[toc]

Introduction

In this article, we are going to create Microsoft Azure Cognitive Service Face API in half an hour. Microsoft Azure Cognitive Services are set of APIs and Services available for the developers to make their applications more interactive and intelligent. This was formerly known as Project Oxford. Here Microsoft uses Machine Learning in the background to create these APIs. So far we have the preceding list of APIs.

  • Emotion and video detection
  • Facial Recognition
  • Speech Recognition
  • Vision Recognition
  • Speech and language understanding

Prerequisites

  • Azure Subscription
  • Visual Studio

If you don’t have any Azure subscription, please sign up for a subscription here.

Download the source code

You can always download the source code used for this video from here

Create the Face API in Azure portal

To know how to create a Face Recognition API in Azure portal, please see the video preceding.

Add reference of Microsoft.ProjectOxford.Face to your project

Before we start coding, please make sure that you add the reference of Microsoft.ProjectOxford.Face from NuGet package manager.

Microsoft.ProjectOxford.Face
Microsoft.ProjectOxford.Face

Using the code

To get started, open your Visual Studio and create a new WPF application.

Add Image and button control to MainWindow.xaml

<button></button>

Create an instance of IFaceServiceClient

If you are selecting the location as Southeast Asia while creating the Face API in portal, it is mandatory to use the second parameter, that is, your end point.

Load the image to image control

Detect the faces count

Draw the rectangles in faces found

Output

Now run your application and upload an image, it can be a single picture or a group picture.

Azure Face Recognition API Output
Azure Face Recognition API Output

Check the statistics in Azure portal

If everything goes fine, you will be able to see the statistics in your Azure portal as preceding.

Face API Metric In Azure Portal
Face API Metric In Azure Portal

To Do

If you would like to compare the images or identify the person in an image, please read the documentation here Face identifying and comparing with Azure Face API

Conclusion

Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.

Your turn. What do you think?

A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.

Kindest Regards
Sibeesh Venu

Leave a Reply

Your email address will not be published. Required fields are marked *

Serverless 360