In this article, we are going to create Microsoft Azure Cognitive Service Face API in half an hour. Microsoft Azure Cognitive Services are sets 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. You can always see this article on my blog here.
- 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 here.
Add the reference to Microsoft.ProjectOxford.Face to your project
Before we start coding, please make sure that you add the reference to Microsoft.ProjectOxford.Face from NuGet package manager.

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
- <Grid>
- <Image Stretch="UniformToFill" x:Name="FaceImage" HorizontalAlignment="Left" Margin="0,0,0,30" />
- <Button x:Name="BtnUpload" VerticalAlignment="Bottom" Content="Upload the image" Margin="20,5" Height="20" Click="BtnUpload_Click" />
- </Grid>
Create an instance of IFaceServiceClient
- private readonly IFaceServiceClient _faceServiceClient = new FaceServiceClient("key", "end point");
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
- private async void BtnUpload_Click(object sender, RoutedEventArgs e)
- {
- //Uploading the image
- var openFrame = new Microsoft.Win32.OpenFileDialog
- {
- Filter = "JPEG Image(*.jpg)|*.jpg"
- };
- var result = openFrame.ShowDialog(this);
- if (!(bool) result) return;
- var filePath = openFrame.FileName;
- var fileUri = new Uri(filePath);
- var bitMapSource = new BitmapImage();
- bitMapSource.BeginInit();
- bitMapSource.CacheOption = BitmapCacheOption.None;
- bitMapSource.UriSource = fileUri;
- bitMapSource.EndInit();
- FaceImage.Source = bitMapSource;
- }



Prakash TripathiPosted Jul 18, 2017, 3:14 AM
Good going buddy, full on webinar, video and now article.