You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to pass languageHints parameter to document_text_detection or (client.annotate_image) as described here but I get error with following Traceback:
File ".../virtual/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 545, in _GetFieldByName
return message_descriptor.fields_by_name[field_name]
KeyError: 'imageContext'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../common/google_vision.py", line 55, in ocr_by_vision
resp = client.document_text_detection(image=image, imageContext={"languageHints": ["it"]})
File ".../virtual/lib/python3.6/site-packages/google/cloud/vision_helpers/decorators.py", line 111, in inner
response = self.annotate_image(request, retry=retry, timeout=timeout)
File ".../virtual/lib/python3.6/site-packages/google/cloud/vision_helpers/__init__.py", line 67, in annotate_image
r = self.batch_annotate_images([request], retry=retry, timeout=timeout)
File ".../virtual/lib/python3.6/site-packages/google/cloud/vision_v1/gapic/image_annotator_client.py", line 218, in batch_annotate_images
requests=requests, )
File ".../virtual/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 503, in init
copy.add(**val)
File ".../virtual/lib/python3.6/site-packages/google/protobuf/internal/containers.py", line 372, in add
new_element = self._message_descriptor._concrete_class(**kwargs)
File ".../virtual/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 484, in init
field = _GetFieldByName(message_descriptor, field_name)
File ".../virtual/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 548, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message AnnotateImageRequest has no "imageContext" field.
To reproduce I tried :
from google.cloud import vision
from google.cloud.vision import types as vision_types
path = '/tmp/0.jpg'
client = vision.ImageAnnotatorClient()
with open(path, 'rb') as image_file:
content = image_file.read()
image = vision_types.Image(content=content)
resp = client.document_text_detection(image=image, imageContext={"languageHints": ["it"]})
@goolila The link you reference above is for the REST version of the Vision API, but google-cloud-vision wraps only the RPC version, which uses names_with_underscores rather than namesWithCamelCase. Your examples should therefore read::
I want to pass
languageHints
parameter to document_text_detection or (client.annotate_image) as described here but I get error with following Traceback:To reproduce I tried :
or
Python Version: 3.6.4
google-cloud-vision Version: 0.34.0
OS: MacOS 10.14
Is there anyway to pass imageContext optional parameters? (I guess some fix like this is needed)
The text was updated successfully, but these errors were encountered: