Bing Emotion API-Cognitive Services-part3

In this tutorial we will learn how to use Bing Emotion API ,In our previous example of cognitive demo we had combine two cognitive services Bing Speech API and Bing Emotion API using that we are finding images using speech  to text(STT). To Extend this demo we will be using Bing Emotion API which will detect the emotion of person from the image that we had searched using Bing Image Search API. I would highly recommend you to go through previous to parts before starting with this demo.

Part1 , Part2

To register for Bing Emotion API follow the steps.

  1. Navigate to https://azure.microsoft.com/en-us/try/cognitive-services/
  2. Navigate to Vision tab and select Bing Emotion api and press get api key.Emotion.png
  3. Select I agree and Your region as shown in imageregion
  4. Login With Microsoft account to get your api keysign_in
  5. Save your keyKey.png

 

Now from Part2 ,we already had the url of the searched image using Bing Image Search API, So will use the same url to get the emotion of person Using Bing Emotion API. We will simply create one method named as GetEmotion which takes String Url of image.( which we already have in part2)

 

 

This Method will make post call to Bing Emotion API with required parameters and API will return the json result. To store this json result we will create one class and named it EmotionResponse  again it is an optional ,one can directly bind the json result.

 

First download the part2 from here, then follow the steps.

 

  • Replace Design MainWindow.xaml with this
  • Replace MainWindow.xaml.cs with below
  • Also add two classes to store Json Response of Emotion API EmotionRequest and EmotionResponse

 

 

Source Code

Output:

Output.png

Advertisements

Leave a Reply

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s