14

Vision API リクエスト スキーマに関するドキュメントを読んでいます。画像ソースには、GCS 画像パスの URL を使用するオプションのみが表示されます。http://example.com/images/image01.jpgのような外部画像 URL を使用することは可能ですか?

4

5 に答える 5

4

はい、できますが、Google クラウド ストレージの URL のみを使用してください。これを試して:

{
  "requests": [
    {
      "image": {
        "source": {
          gcsImageUri: 'gs://something.com/image',
        },
      },
      "features": ...
      "imageContext": ...
    },
  ]
}
于 2016-03-10T00:45:24.900 に答える
2

Pythonユーザー向けの回答。

def detect_labels_uri(uri):
    """Detects labels in the file located in Google Cloud Storage or on the
    Web."""
    from google.cloud import vision
    client = vision.ImageAnnotatorClient()
    image = vision.types.Image()
    image.source.image_uri = uri

    response = client.label_detection(image=image)
    labels = response.label_annotations
    print('Labels:')

    for label in labels:
        print(label.description)
# [END vision_label_detection_gcs]
于 2019-06-23T10:06:19.790 に答える