Vision API Demo

Length: 00:13:28

Lesson Summary:

We will demonstrate working with the Vision API service in this lesson. The commands we used to authenticate with our API key, create request.json file, and the curl command used to call on the API are below for your reference.

  1. Authenticate with your API key after creating the API credential:

    export API_KEY=(your copied key)

  2. Create your JSON file by typing:

    vim request.json

  3. Then copy/paste the following text, substituting the Cloud Storage info with your actual Cloud Storage bucket and object info:

    "requests": [
       {
         "image": {
           "source": {
               "gcsImageUri": "gs://(your_bucket)/(your_image_file)"
           } 
         },
         "features": [
           {
             "type": "LABEL_DETECTION",
             "maxResults": 10
           },
           {
             "type": "WEB_DETECTION",
             "maxResults": 10
           },
           {
             "type": "FACE_DETECTION"
           }
         ]
       }
    ]
    }
    
  4. Use the below command to authenticate with the Vision API using your API key, and supplying the request.json file we just created:

    curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json https://vision.googleapis.com/v1/images:annotate?key=${API_KEY}


This lesson is only available to Linux Academy members.

Sign Up To View This Lesson
Or Log In

Looking For Team Training?

Learn More