所以我知道google-vision api支持多种语言的文本检测。通过使用下面的代码,我可以从图像中检测英语语言。但是根据google的说法,我可以使用参数language hints来检测其他语言。那么,在下面的代码中,我到底应该把这个参数放在哪里呢?
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')发布于 2019-03-27 04:22:13
如下所示:
response = client.text_detection(
image=image,
image_context={"language_hints": ["bn"]}, # Bengali
)有关更多详细信息,请参阅"ImageContext"。
https://stackoverflow.com/questions/55364164
复制相似问题