Reputation: 138
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?
Upvotes: 9
Views: 330
Reputation: 31339
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.
Upvotes: 3