[英]Add languageHints to Google Cloud Vision
how can I add languageHints to my google cloud vision python code. 如何将languageHints添加到我的google cloud vision python代码。 From https://cloud.google.com/vision/docs/languages I know that it is supported but I do not know how to implement it into the code.
从https://cloud.google.com/vision/docs/languages中,我知道它受支持,但是我不知道如何在代码中实现它。
from google.cloud import vision
client = vision.ImageAnnotatorClient()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = vision.types.Image(content=content)
response = client.text_detection(image=image)
texts = response.text_annotations
print('Texts:')
for text in texts:
print('\n"{}"'.format(text.description))
vertices = (['({},{})'.format(vertex.x, vertex.y)
for vertex in text.bounding_poly.vertices])
print('bounds: {}'.format(','.join(vertices)))
I think I have to do it like this: 我认为我必须这样做:
context = imageContext.setLanguageHints("ko")
response = client.text_detection(image=image, context=context)
Even though it's late, I hope this help's another people. 即使已经很晚了,我希望这对其他人有所帮助。
Based on this , you could do something like this: 基于此 ,您可以执行以下操作:
image = vision.types.Image(content=content)
context = vision.types.ImageContext(language_hints=['ko'])
response = client.text_detection(image=image, image_context=context)
Note that the language_hints
parameter expects a list. 请注意,
language_hints
参数需要一个列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.