Reader small image

You're reading from  Learning Microsoft Cognitive Services

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786467843
Edition1st Edition
Languages
Right arrow
Author (1)
Leif Larsen
Leif Larsen
author image
Leif Larsen

Leif Larsen is a software engineer based in Norway. After earning a degree in computer engineering, he went on to work with the design and configuration of industrial control systems, for the most part, in the oil and gas industry. Over the last few years, he has worked as a developer, developing and maintaining geographical information systems, working with .NET technology. Today, he is working with a start-up, developing a brand new SaaS product. In his spare time, he develops mobile apps and explores new technologies to keep up with the high-paced tech world. You can find out more about him by checking out his blog, "Leif Larsen", and following him on Twitter (@leif_larsen) and LinkedIn (lhlarsen).
Read more about Leif Larsen

Right arrow

Chapter 2. Analyzing Images to Recognize a Face

"We can use the Computer Vision API to prove to our clients the reliability of the data, so they can be confident making important business decisions based on that information."                                                                                      - Leendert de Voogd, CEO Vigiglobe

In the previous chapter, you were briefly introduced to Microsoft Cognitive Services. Throughout this chapter, we will dive into image-based APIs from the Vision API. We will learn how to do image analysis. Moving on, we will dive deeper into the Face API, which we briefly looked at in the first chapter. We will end the chapter by looking at how you can identify people.

In this chapter, we will cover the following topics:

  • Analyzing images to identify content, metadata, and adult rating

  • Recognize celebrities in images and read text in images

  • Dive into the Face API:

    1. Learn to find the likelihood of two faces belonging to the same person

    2. Group faces based...

Learning what an image is about using Computer Vision API


The Computer Vision API allows us to process an image and retrieve information about it. It relies on advanced algorithms to analyze the content of the image in different ways, based on our needs.

Throughout this part of the chapter, we will learn how to take advantage of this API. We will look at the different ways to analyze an image through standalone examples. Some of the features we will cover will also be incorporated into our end-to-end application in a later chapter.

Calling any of the APIs, will return one of the following response codes:

Diving deep into the Face API


The Face API has two main features. The first one is face detection, and the other is face recognition.

Face detection allows one to detect up to 64 faces in one image. We have already seen the basic usage. The features of face recognition are implied in its name. Using it, we can detect if two faces belong to the same person. We can find similar faces, or one in particular, and we can group similar faces. We will learn how to do all of this in the following pages.

When calling any of the APIs it will respond with one of the following responses:

Code

Description

200

Information of the extracted features in JSON format

400

Typically, this means bad request. It may be an invalid image URL, too small or too large image, invalid image format, or otherwise errors around the request body.

415

Unsupported media type

500

Possible errors may be a failure to process the image, image processing timed out, or there is an internal...

Adding identification to our Smart-House application


As a part of our Smart-House application, we want the application to recognize who we are. Doing so opens up the opportunity to get responses and actions from the application, tailored to you.

Creating our Smart-House application

Create a new project for the Smart-House application, based on the MVVM template we created earlier.

With the new project created, add the Microsoft.ProjectOxford.Face NuGet package.

As we will be building this application throughout the book, we will start small. In the MainView.xaml file add a TabControl property containing two items. The two items should be two user controls, one called the AdministrationView.xaml file, and one called the HomeView.xaml file.

The administration control will be where we administer different parts of the application. The home control will be the starting point, and the main control to use.

Add corresponding ViewModels to the Views. Make sure they are declared and created in MainViewModel...

Summary


In this chapter, we have taken a deep dive into a big part of the Vision APIs. We learned how to get good descriptions of images. Next we learned how to recognize celebrities and text in images. We saw how we can generate thumbnails. Following this, we moved on to the Face API, where we got more information about detected faces. We found out how to verify if two faces were the same. After this we learned how to find similar faces and group similar faces. Finally, we added identification to our Smart-House application, allowing it to know who we are.

The following chapter will continue with the final two Vision APIs. We will learn how to detect emotion in images and videos. Moving on from there, we will focus more on videos, discovering what the Video API has to offer.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Microsoft Cognitive Services
Published in: Mar 2017Publisher: PacktISBN-13: 9781786467843
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Leif Larsen

Leif Larsen is a software engineer based in Norway. After earning a degree in computer engineering, he went on to work with the design and configuration of industrial control systems, for the most part, in the oil and gas industry. Over the last few years, he has worked as a developer, developing and maintaining geographical information systems, working with .NET technology. Today, he is working with a start-up, developing a brand new SaaS product. In his spare time, he develops mobile apps and explores new technologies to keep up with the high-paced tech world. You can find out more about him by checking out his blog, "Leif Larsen", and following him on Twitter (@leif_larsen) and LinkedIn (lhlarsen).
Read more about Leif Larsen

Code

Description

200

Successful call. Returns an array containing data related to the API call.

400

Request body is invalid. Can be a number of errors, depending on the API call. Typically, the request code is invalid.

401

Access denied due to invalid subscription key. The key may be wrong, or the account/subscription plan is blocked.

403

Out of call volume data. You have made all the available calls to the...