5

如何调用 Vision API 并在图像上应用多个功能。我想在图像上同时应用标签检测和地标检测

4

2 回答 2

2

您可以如下定义您的请求,以便为每个图像合并多个功能请求

    "requests":[
    {
      "image":{
        "content":"/9j/7QBEUGhvdG9zaG9...image contents...fXNWzvDEeYxxxzj/Coa6Bax//Z"
      },
      "features":[
        {
          "type":"FACE_DETECTION",
          "maxResults":10
        },
        {
          "type":"LABEL_DETECTION",
          "maxResults":10
        }
      ]
    }
  ]
}  
于 2016-02-05T17:45:22.067 回答
1
from google.cloud import vision
import os 

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/path/client.json"

client = vision.ImageAnnotatorClient()
response = client.annotate_image({
      'image': {'source': {'image_uri': 'gs://yourbuket/1.jpg'}},
      'features': [{'type': vision.enums.Feature.Type.LABEL_DETECTION},
      {'type': vision.enums.Feature.Type.FACE_DETECTION}],
    })
于 2019-05-30T15:58:14.533 回答