How to improve Google Vision results while detecting a text on an image if we know the language of

二次信任 提交于 2019-12-13 03:19:21

问题


How to modify the following Python code to return results in German? Is it possible? Thank you.

def detect_text_uri(uri):
    """Detects text in the file located in Google Cloud Storage or on the Web.
    """
    client = vision.ImageAnnotatorClient()
    image = types.Image()
    image.source.image_uri = uri

    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)))

回答1:


Yes, you can specify it using "languageHints": [ "de"]

{
  "requests": [
    {
      "imageContext": {
        "languageHints": ["de"]
      }
    }
  ]
}

For all types of language codes, check supported Google vision languages



来源:https://stackoverflow.com/questions/49096942/how-to-improve-google-vision-results-while-detecting-a-text-on-an-image-if-we-kn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!