我正在为 Google Cloud Vision API 使用 Python 客户端,与文档http://google-cloud-python.readthedocs.io/en/latest/vision/中的代码基本相同
>>> from google.cloud import vision
>>> client = vision.ImageAnnotatorClient()
>>> response = client.annotate_image({
... 'image': {'source': {'image_uri': 'gs://my-test-bucket/image.jpg'}},
... 'features': [{'type': vision.enums.Feature.Type.FACE_DETECTOIN}],
... })
问题是响应没有字段“注释”(因为它是文档),但基于文档有每个“类型”的字段。因此,当我尝试获取 response.face_annotations 时,我得到了并且基本上我不知道如何从响应 (AnnotateImageResponse) 中提取 Vision API 的结果以获取类似 json/dictionary 之类的数据。google-cloud-vision 的版本是 0.25.1,它被安装为完整的 google-cloud 库(pip install google-cloud)。我认为今天不是我的日子我感谢任何澄清/帮助