Quickstart: Integrating Azure Cognitive Services Face Detection API with .NET Core

In this article we are specifically looking at Azure Cognitive Services Face Detection API. At a minimum, each detected face corresponds to a faceRectangle field in the response. This set of pixel coordinates for the left, top, width, and height mark the located face. Using these coordinates, you can get the location of the face and its size. In the API response, faces are listed in size order from largest to smallest.

  • Basic understanding about .NET Core/ C#
  • Blur. The blurriness of the face in the image. This attribute returns a value between zero and one and an informal rating of low, medium, or high.
  • Emotion. A list of emotions with their detection confidence for the given face. Confidence scores are normalized, and the scores across all emotions add up to one. The emotions returned are happiness, sadness, neutral, anger, contempt, disgust, surprise, and fear.
  • Exposure. The exposure of the face in the image. This attribute returns a value between zero and one and an informal rating of underExposure, goodExposure, or overExposure.
  • Facial hair. The estimated facial hair presence and the length for the given face.
  • Gender. The estimated gender of the given face. Possible values are male, female, and genderless.
  • Glasses. Whether the given face has eyeglasses. Possible values are NoGlasses, ReadingGlasses, Sunglasses, and Swimming Goggles.
  • Hair. The hair type of the face. This attribute shows whether the hair is visible, whether baldness is detected, and what hair colors are detected.
  • Makeup. Whether the face has makeup. This attribute returns a Boolean value for eyeMakeup and lipMakeup.
  • Noise. The visual noise detected in the face image. This attribute returns a value between zero and one and an informal rating of low, medium, or high.
  • Occlusion. Whether there are objects blocking parts of the face. This attribute returns a Boolean value for eyeOccluded, foreheadOccluded, and mouthOccluded.
  • Smile. The smile expression of the given face. This value is between zero for no smile and one for a clear smile.

Okay! let’s start.

Visit https://portal.azure.com/#create/Microsoft.CognitiveServicesFace, you will be prompted to login, if you don’t have an Azure account, you might want to create one.

Install-Package Microsoft.Azure.CognitiveServices.Vision.Face -Version 2.5.0-preview.1
dotnet add package Microsoft.Azure.CognitiveServices.Vision.Face --version 2.5.0-preview.1
foreach (var face in detectedFaces.Select((value, i) => new { i, value }))
{
double age = face.value.FaceAttributes.Age;}

Systems Design • Social Innovation • Cloud • ML