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
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)
OS type and version
OSX 10.11
Python version and virtual environment information
python --versionPython 2.7.12
google-cloud-python version
pip show google-cloud,pip show google-<service>orpip freezegoogle-cloud-vision==0.22.0
Stacktrace if available
The following code exercises the crash: