如果我们知道图像的语言,如何在检测图像上的文本时改善Google视觉结果 [英] How to improve Google Vision results while detecting a text on an image if we know the language of

查看:109
本文介绍了如果我们知道图像的语言,如何在检测图像上的文本时改善Google视觉结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修改以下Python代码以德语返回结果?是否有可能?谢谢.

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

推荐答案

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

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

对于所有类型的语言代码,请检查支持的Google视觉语言

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

这篇关于如果我们知道图像的语言,如何在检测图像上的文本时改善Google视觉结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆