Итак, я знаю, что api google-vision поддерживает несколько языков для обнаружения текста. И используя приведенный ниже код, я могу определить английский язык по изображению. Но, согласно Google, я могу использовать подсказки языка параметров для обнаружения других языков. Итак, где именно я должен поместить этот параметр в приведенный ниже код?
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')