Не удается отправить строку в кодировке base64 в API Google Vision - PullRequest
0 голосов
/ 05 марта 2019

Я хочу отправить закодированную в base64 строку изображения в Googles Vision API, но не могу понять, как это сделать.Как мне это сделать?

Мой код

@staticmethod
def get_text_detection_from_img(img_name):       
    credentials = service_account.Credentials.from_service_account_file("key.json")
    client = vision.ImageAnnotatorClient(credentials=credentials)

    with open(img_name, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())

    response = client.annotate_image(
        {"image": {"content": encoded_string}, "features":
            [{'type': vision.enums.Feature.Type.TEXT_DETECTION}]})

    print(response)
...