In this article, you will learn how to consume cognitive services for recognizing a celebrity in Xamarin.Android by using a mobile camera. I hope you will learn some cool stuff in Xamarin using cognitive services.

Prerequisites

Computer Vision API Key

Microsoft.Net.Http

Newtonsoft.Json

Computer Vision API keys

Computer vision services require special subscription keys. Every call to the Computer Vision API requires a subscription key. This key needs to be either passed through a query string parameter or specified in the request header.

To sign up for subscription keys, see Subscriptions. It's free to sign up. Pricing for these services is subject to change.

If you sign up using the Computer Vision free trial, your subscription keys are valid for the west-central region (https://westcentralus.api.cognitive.microsoft.com).

The steps given below are required to be followed in order to create a Celebrities Recognize app in Xamarin.Android, using Visual Studio.

Step 1 - Create an Android Project

Create your Android solution in Visual Studio or Xamarin Studio. Select Android and from the list, choose Android Blank App. Give it a name, like RecognizeCelebritiesbyCamera.

(ProjectName: RecognizeCelebritiesbyCamera)

Step 2 - Add References of Nuget Packages

First of all, in References, add the reference of Microsoft.Net.Http and Newtonsoft.Json using NuGet Package Manager, as shown below.

Step 3 - User Interface

Open Solution Explorer-> Project Name-> Resources-> Layout-> Main.axml and add the following code. The layout will have an ImageView in order to display the preview of Celebrities image. I also added a TextView to display the contents of the Celebrities and two buttons.