In this article, I will show you how to consume computer vision API in xamarin.android for analyzing images. I hope you will learn the latest things 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 westcentral region (https://westcentralus.api.cognitive.microsoft.com).

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

Step 1 - Create 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 ImageAnalyze.

(ProjectName: ImageAnalyze)

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 a ImageView in order to display the preview of sample image. I also added a TextView to display the contents of the Image.