Computer Vision API – Analyze Image

The Computer Vision API v2.0 is a REST API and provides state-of-the-art algorithms to process images and provide information related to the images. The “Analyze” operation of Computer Vision API analyzes the uploaded image and provides rich visual features about the image. Rich visual features include

  • Adult
  • Brands
  • Categories
  • Color
  • Description
  • Faces
  • ImageType
  • Objects,Tags

API referencehttps://bit.ly/2kFIsh3

Pre-requisites

  • Computer Vision service or Cognitive Services provisioned on Azure
  • Postman App

Image Requirements

  • Supported image formats: JPEG, PNG, GIF, BMP.
  • Image file size must be less than 4MB.
  • Image dimensions must be between 50 x 50 and 4200 x 4200 pixels, and the image cannot be larger than 10 megapixels.

Analyze Image Operation

  • Launch Postman
  • Append your endpoint URL from pre-requisites step with /vision/2.0/analyze and provide the query parameters as shown below.
  • Provide the subscription key and content-type in Headers tab
  • Provide the image URL in the Body tab.
  • Following image is provided in blob URL
  • Click ‘Send’ and you will get the output as json. Note: Sachin Tendulkar from the image has been identified as celebrity.
  • The complete output is shown below. Interesting that it detected ‘Cricket’ bat as ‘Baseball’ bat.
{
   "categories": [
     {
       "name": "people_group",
       "score": 0.34375,
       "detail": {
         "celebrities": [
           {
             "name": "Sachin Tendulkar",
             "confidence": 0.9999932050704956,
             "faceRectangle": {
               "left": 210,
               "top": 189,
               "width": 80,
               "height": 80
             }
           }
         ]
       }
     }
   ],
   "adult": {
     "isAdultContent": false,
     "isRacyContent": false,
     "adultScore": 0.0358833372592926,
     "racyScore": 0.040996238589286804
   },
   "color": {
     "dominantColorForeground": "White",
     "dominantColorBackground": "Grey",
     "dominantColors": [
       "Grey"
     ],
     "accentColor": "1968B2",
     "isBwImg": false,
     "isBWImg": false
   },
   "imageType": {
     "clipArtType": 0,
     "lineDrawingType": 0
   },
   "tags": [
     {
       "name": "person",
       "confidence": 0.9994388818740845
     },
     {
       "name": "player",
       "confidence": 0.982375979423523
     },
     {
       "name": "soccer",
       "confidence": 0.9047091007232666
     },
     {
       "name": "sports uniform",
       "confidence": 0.903242826461792
     },
     {
       "name": "man",
       "confidence": 0.8699029684066772
     },
     {
       "name": "football",
       "confidence": 0.8643859028816223
     },
     {
       "name": "baseball",
       "confidence": 0.7640540599822998
     },
     {
       "name": "sports equipment",
       "confidence": 0.6519014239311218
     },
     {
       "name": "hand",
       "confidence": 0.5871903896331787
     },
     {
       "name": "human face",
       "confidence": 0.5362251996994019
     },
     {
       "name": "arm",
       "confidence": 0.23963892459869385
     },
     {
       "name": "male",
       "confidence": 0.1807997226715088
     }
   ],
   "description": {
     "tags": [
       "person",
       "player",
       "man",
       "holding",
       "baseball",
       "ball",
       "hand",
       "game",
       "uniform",
       "wearing",
       "bat",
       "blue",
       "field",
       "throwing",
       "standing",
       "young",
       "air",
       "playing",
       "pitch",
       "pitcher",
       "doing"
     ],
     "captions": [
       {
         "text": "Sachin Tendulkar in a blue uniform holding a baseball bat",
         "confidence": 0.46406672073844357
       }
     ]
   },
   "faces": [
     {
       "age": 38,
       "gender": "Male",
       "faceRectangle": {
         "left": 210,
         "top": 189,
         "width": 80,
         "height": 80
       }
     }
   ],
   "objects": [
     {
       "rectangle": {
         "x": 20,
         "y": 139,
         "w": 426,
         "h": 361
       },
       "object": "person",
       "confidence": 0.722
     }
   ],
   "brands": [],
   "requestId": "21af3a9a-1711-4e8a-b1f0-ef11682b0077",
   "metadata": {
     "width": 674,
     "height": 500,
     "format": "Jpeg"
   }
 }
  • If we upload an image as shown below, it will detect the brand in the image as “Nike”
  • If we upload an image as shown below, it will recognize the landmark in the image as “Taj Mahal”

Leave a Reply

Your email address will not be published. Required fields are marked *