【问题标题】:Where to use Language hints in google-vision text-detection api?在 google-vision text-detection api 中何处使用语言提示?
【发布时间】:2019-03-26 18:40:07
【问题描述】:

所以我知道 google-vision api 支持多种语言进行文本检测。通过使用下面的代码,我可以从图像中检测到英语。但根据谷歌我可以使用参数语言提示来检测其他语言。那么我到底应该把这个参数放在下面的代码中的什么地方呢?

def detect_text(path):
    """Detects text in the file."""
    from google.cloud import vision
    imageContext = 'bn'
    client = vision.ImageAnnotatorClient(imageContext)

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


detect_text('Outline-of-the-Bangladesh-license-plates_Q320.jpg')


【问题讨论】:

    标签: python-3.x api google-cloud-platform google-vision


    【解决方案1】:

    像这样:

    response = client.text_detection(
        image=image,
        image_context={"language_hints": ["bn"]},  # Bengali
    )
    

    更多详情请见"ImageContext"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      相关资源
      最近更新 更多