如果我们知道图像的语言,如何在检测图像上的文本时如何改进Google Vision结果

问题描述 投票:0回答:1

如何修改以下Python代码以返回德语结果?可能吗?谢谢。

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)))
python google-vision text-recognition
1个回答
0
投票

是的,您可以使用"languageHints": [ "de"]指定它

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

对于所有类型的语言代码,请检查supported Google vision languages

© www.soinside.com 2019 - 2024. All rights reserved.