我在GCS上有一堆图片,想弄清楚它们是什么?如何使用存储在Google云端存储中的图像调用Google Vision API?
5
A
回答
5
对于GCS集成 - 我只想修改上面的身体指向GCS位置用gcs_image_uri替换内容属性
2
Vision API可以通过REST API调用访问。您传入JSON请求,其中嵌入了图像或链接到GCS中的图像。然后,您可以传入要在图像上运行的功能。这是作为JSON请求传入的,响应对象包含注释。以下是调用Vision API的Python代码片段。
DISCOVERY_URL='https://{api}.googleapis.com/$discovery/rest?version={apiVersion}'
credentials = GoogleCredentials.get_application_default()
service = discovery.build('vision', 'v1', credentials=credentials,
discoveryServiceUrl=DISCOVERY_URL)
with open(photo_file, 'rb') as image:
image_content = base64.b64encode(image.read())
service_request = service.images().annotate(
body={
'requests': [{
'image': {
'content': image_content
},
'features': [{
'type': 'LABEL_DETECTION', # Feature to detect
'maxResults': 1,
}]
}]
})
response = service_request.execute()
label = response['responses'][0]['labelAnnotations'][0]['description']
有关其他信息,您不妨看看Label Detection Tutorial
相关问题
- 1. 来自Google Vision API的空回复与存储在Google云端存储中的图像
- 2. 如何使用Google云端存储压缩图像/视频create_upload_url
- 3. 使用Python的Google云端存储
- 4. 使用Google云端存储的Apache Drill
- 5. 如何在存储在Google云端存储中的文件上使用cv2.imread?
- 6. “jQuery”“Google云端存储”
- 7. Google云端存储传播
- 8. Firebase和Google云端存储API
- 9. Google云端存储文档缩略图?
- 10. 如何在Google云端存储中使用OAuth2Decorator?
- 11. Git使用Google云端存储的大型文件存储
- 12. 使用S3 interop API在Google云端存储中列出对象
- 13. 在Android中使用Google云端存储JSON api
- 14. 让Google Cloud Vision API访问Firebase存储
- 15. 适用于iOS的Google云端存储
- 16. 在Google云端存储中存储关键值类似于Google云端存储中的数据
- 17. 如何将Firebase存储图像与Google Cloud Vision API配合使用?
- 18. Google云端存储 - 应用程序中的存储区权限
- 19. 使用Node.js和Google云端存储压缩图像
- 20. 如何设置公开的Google云端存储存储桶
- 21. 使用CloudFlare将CDN存储到Google云端存储桶
- 22. Google Apps脚本:如何在Google云端存储中存储数据?
- 23. 如何使用PHP从Google云端存储中删除对象?
- 24. 如何使用Google云端存储管理缓存
- 25. 如何将图像从Expressjs更新到Google云端存储/ Firebase存储
- 26. BigQuery中的Google云端存储桶
- 27. Google Appengine云存储
- 28. 使用Google App Engine的Google云端存储签名URL
- 29. 如何让Google Vision API在同一个项目中访问Google云端存储分区
- 30. 哪个是Google API使用Android应用文件存储的最佳方式? Google Drive sdk或Google云存储API?