-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: visionIssues related to the Cloud Vision API.Issues related to the Cloud Vision API.
Description
-
OS type and version
OSX 10.11 -
Python version and virtual environment information
python --version
Python 2.7.12 -
google-cloud-python version
pip show google-cloud,pip show google-<service>orpip freeze
google-cloud-vision==0.22.0 -
Stacktrace if available
cls = <class 'google.cloud.vision.annotations.Annotations'>
response = {'fullTextAnnotation': {'pages': [{'blocks': [{'blockType': 'TEXT', 'boundingBox': {...}, 'paragraphs': [...], 'proper... [{'x': 317, 'y': 506}, {'x': 337, 'y': 507}, {'x': 335, 'y': 536}, {'x': 315, 'y': 535}]}, 'description': 'to'}, ...]}
@classmethod
def from_api_repr(cls, response):
"""Factory: construct an instance of ``Annotations`` from a response.
:type response: dict
:param response: Vision API response object.
:rtype: :class:`~google.cloud.vision.annotations.Annotations`
:returns: An instance of ``Annotations`` with detection types loaded.
"""
annotations = {}
for feature_type, annotation in response.items():
> curr_feature = annotations.setdefault(_KEY_MAP[feature_type], [])
E KeyError: u'fullTextAnnotation'
env/lib/python2.7/site-packages/google/cloud/vision/annotations.py:91: KeyError
- Steps to reproduce
- Enable API backend with extra data in response to detect_text
- Call detect_text
- Extra content in response body crashes the client library
- Code example
The following code exercises the crash:
def detect_text(path):
"""Detects text in the file."""
vision_client = vision.Client()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = vision_client.image(content=content)
texts = image.detect_text()
print('Texts:')
for text in texts:
print(text.description)
Metadata
Metadata
Assignees
Labels
api: visionIssues related to the Cloud Vision API.Issues related to the Cloud Vision API.