Computer Vision API - Methods and Models

When working with the Computer Vision API we need to understand what methods we can use for the API.

A good resource of information is the Computer Vision Documentation , this Blog will be focused on utilizing the Computer Vision API with C# but there are multiple programing languages that these Cognitive Services APIS can be developed with.

An important concept to understand is the API Methods which get passed in with the Endpoint URL. These Methods tell the API that you are contacting what it is you wish to utilize that API for.

With the Analyze Image method, you can extract visual features based on image content. You can upload an image or specify an image URL and choose which features to return, including:

You can also utilize Domain-Specific Models Such as Celebrities and Landmarks, these 2 models can be used to analyze data (image / video) and identify Places of known interest such as the Empire States Building , The White House, The Leaning Tower of Pisa etc. If an image is sent to the Computer Vision API using the Landmark model, the image is “analyzed” and the API tries to determine where the image takes place. The Celebrity Model is used to identify Known Celebrities, if an image is sent to the Computer Vision API using the Celebrity Model the API would try to identify any people that it recognizes in the image. If you submitted an image with you standing next to Arnold Schwarzenegger, the API would probably be able to determine that you are standing next to Arnold Schwarzenegger but may not be able to identify you specifically and would return a result for you that the API thinks best matches you.

Lets take a look at some of these Methods and Models and how we use them

First lets look at the Endpoint URL for the Computer Vision API

  1. Log into your Azure Portal
  2. Look for the Computer Vision API you set up under Cognitive Services
    • If you have not done this already Follow this guide to do so.
  3. Looking at Your Computer Vision API you should see something like this

 

The Endpoint URL which I believe is the same for everyone but I would double check should look like the following https://westus.api.cognitive.microsoft.com/vision/v1.0

When working with a method like analyze the Endpoint URL is appended with the name of the Method like this

https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze

When working with a Model such as Landmark the Endpoint URL is appended with the Model and the Method and looks like this

https://westus.api.cognitive.microsoft.com/vision/v1.0/models/landmarks

Some other examples of Methods are:

generateThumbnail

https://westus.api.cognitive.microsoft.com/vision/v1.0/generateThumbnail

ocr

https://westus.api.cognitive.microsoft.com/vision/v1.0/ocr

recognizeText

https://westus.api.cognitive.microsoft.com/vision/v1.0/recognizeText

Using the Celebrity Model would look like this

https://westus.api.cognitive.microsoft.com/vision/v1.0/models/celebrities