Computer Vision - C# Code Sample

The Computer Vision APIs are a collection of state-of-the-art image processing algorithms designed to return information based on the visual content, and to generate your ideal thumbnail. The Computer Vision APIs mainly includes analyzing an image, Generating a thumbnail and OCR.
Here is a sample code using C# to analyze an image You can find a testing console along with other code samples in our API reference documentation here.
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
    static class Program
        static void Main()
            Console.WriteLine("Hit ENTER to exit...");
        static async void MakeRequest()
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            // Request parameters
            queryString["visualFeatures"] = "Categories";
            queryString["details"] = "{string}";
            var uri = "" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);


Feedback and Knowledge Base