ENG [#VS2015] Hello Face: #FaceAPIs in a Wpf App (3)


New post for Azure Machine Learning Face APIs series

  1. Face APIs in Azure
  2. Hello Face: Face APIs in a Console App
  3. Hello Face: Face APIs in a WPF App

In the previous post I shared the 10 sample lines that we can user as a Face APIs basic functionality in a console app to :

  • detect faces
  • detect age on each face
  • detect sex on each face

Moreover, another option that does Face APIs provide is the ability to identify the region on the original image for each detected face. In the next example, I’ve added a WPF project and I have referenced the ClientLibrary. It is based on one of the examples in the Face APIs SDKs.

This project has 2 important files

lib \ FaceApiHelper.cs. This class is the one used for image processing using Face APIs service.

UserControls \ Face.cs. Represents a User Control, with an image to show the face, and also a series of labels to show the age and sex.


The MainWindow.xaml main window features a button to select an image of the disk and by under 2 sections showing the original image with boxes on each side found and a list of the found faces. The code by pressing the button is very simple


Important: The key to use the Face API service is part of the settings of the app.

The StartFaceDetection() function returns 2 collections of Faces. One with the information age and sex of the found face, the other is a special object used to “paint” boxes on the original image.


If you’ve been able to see the code and not vomiting with error handling, you can try the application. An example of the app in operation is as follows:

2015 06 02 Face Api Wpf

If you want to see the Special transformation to paint the boxes, you can take a look at CalculateFaceRectangleForRendering() .

The code can be downloaded from https://github.com/elbruno/ProjectOxford/tree/master/Samples

Greetings @ Medrid

/El Bruno


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: