Book Image

Learning Microsoft Cognitive Services

By : Leif Larsen
Book Image

Learning Microsoft Cognitive Services

By: Leif Larsen

Overview of this book

Take your app development to the next level with Learning Microsoft Cognitive Services. Using Leif's knowledge of each of the powerful APIs, you'll learn how to create smarter apps with more human-like capabilities. ? Discover what each API has to offer and learn how to add it to your app ? Study each AI using theory and practical examples ? Learn current API best practices
Table of Contents (20 chapters)
Learning Microsoft Cognitive Services
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
12
Additional Information on Linguistic Analysis

Analyzing emotions in videos


Earlier, we looked at analyzing emotions in images. We can do the same analysis with videos as well.

To be able to do this, we can modify the existing example for the Video API.

Start by adding Microsoft.ProjectOxford.Emotion as a NuGet client package.

Next we add Emotion to the AvailableOperations enum. In the VideoOperations class, add a new case for this value, in CreateVideoOperationSettings. Return null, as we do not need any video-operation settings for this.

Add a private member to VideoOperations:

    private EmotionServiceClient _emotionServiceClient; 

Initialize this in the constructor, using the API key you registered earlier.

In the VideoOperationResultEventArgs, add a new property called EmotionResult. This should be of the type VideoAggregateRecognitionResult.

Back in the VideoOperations class, copy the GetVideoOperationResultAsync function. Rename it to GetVideoEmotionResultAsync, and change the accepted parameter to VideoEmotionRecognitionOperation...