In this article, you will learn how to use Microsoft Cognitive Services from your C# applications.
Introduction
Today, Artificial Intelligence is a very common aspect of our daily life. You can notice that most of the companies are using it to create very powerful and smart apps. On Facebook, while you're uploading a photo, it can automatically recognize your face. Also, the bots are available through Facebook Messenger, Cortana, Telegram, and many more. Using Artificial Intelligence makes your app more secure and robust and provides an interesting User Experience.
For example, if you want to create a home renting website, using Artificial Intelligence will make your project more powerful because you can add an Image Content recognizer to it. So, the home ads publishers won’t be able to upload any type of images except Home's; and your website will be more trusted. Also, using bots to make your users able to chat to your app will be amazing and the users will like your project more.
In this article, I’m going to talk about what Microsoft Cognitive Services is and how to use these APIs within your C# apps.
Microsoft Cognitive Services
Microsoft Cognitive Services is a set of APIs and SDKs that Microsoft created for the developers to make it easy for them to add intelligence to their apps, such as emotion and video detection; facial, speech, and vision recognition; and speech and language understanding – into their apps.
In this article, I will create a simple Windows Forms application and use the Vision API to recognize the content of an image and get the result in a JSON format so that you can manipulate it in a way you prefer.
Note - In this tutorial, I used the Vision API but you can use any of the available APIs with the same steps. Also, you can use any type of applications not only Windows Forms.
Let’s start step by step Sign up for Microsoft Cognitive Services for free from this link, https://azure.microsoft.com/en-us/try/cognitive-services/. Follow the steps and set your region. After you log in, choose "Add Vision API" and you will get your endpoint URL and the API key that you will use in your app. This is all you need to start creating your intelligent app. Open Visual Studio and create a new Windows Forms Project. Add two buttons, a picturebox and a textbox as following. In the code behind file, add the following namespaces:
Double click on the Browse button to create a click event handler for this button and write the following code to select an image from your local drive.
Pro WPF: Windows Presentation Foundation in .NET 3.0