首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在google-vision文本检测api中哪里可以使用语言提示?

在google-vision文本检测api中哪里可以使用语言提示?
EN

Stack Overflow用户
提问于 2019-03-27 02:40:07
回答 1查看 3.7K关注 0票数 6

所以我知道google-vision api支持多种语言的文本检测。通过使用下面的代码,我可以从图像中检测英语语言。但是根据google的说法,我可以使用参数language hints来检测其他语言。那么,在下面的代码中,我到底应该把这个参数放在哪里呢?

代码语言:javascript
复制
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')
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-27 04:22:13

如下所示:

代码语言:javascript
复制
response = client.text_detection(
    image=image,
    image_context={"language_hints": ["bn"]},  # Bengali
)

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

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55364164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档