How to improve Google Vision results while detecti

2019-08-27 05:55发布

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条回答
Lonely孤独者°
2楼-- · 2019-08-27 06:47

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

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

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

查看更多
登录 后发表回答