Google视觉文本检测api在哪里使用语言提示?

时间:2019-03-26 18:40:07

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

所以我知道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')


1 个答案:

答案 0 :(得分:0)

赞:

{0, 1, 2, ... 51}

有关更多详细信息,请参见"ImageContext"