It looks that google-cloud vision Python client (google.cloud.vision.client.Client) doesn't have an option to accept api-key.
https://googlecloudplatform.github.io/google-cloud-python/stable/vision-client.html
How can I use the client with api-key authentication?
I'm only adding this for future readers because no other answer exists for a while now (I've also added a bounty):
from googleapiclient.discovery import build
# ...
service = build('vision', 'v1', developerKey=API_KEY, cache_discovery=False)
image_b64 = base64.b64encode(image_bytes).decode()
return service.images().annotate(body={
'requests': [{
'image': {
'content': image_b64
},
'features': [{
'type': 'DOCUMENT_TEXT_DETECTION',
'maxResults': 5,
}]
}]
}).execute()
This (python) sample obviously does not use the client in question, but this is how I went at it at the moment to do simple OCR.
You can change the features or the image specification to fit your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With