您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Google Cloud Vision不接受Base64编码的图像python

Google Cloud Vision不接受Base64编码的图像python

我没有使用Google Cloud Vision的经验,但是在查看了他们的文档和示例后,我的感觉是,有关图像数据的base64编码链接文档页面适用于您自己创建和发送HTTP请求的情况,无需使用vision.ImageAnnotatorClient。后者似乎是自动对图像数据进行编码,因此在您的示例中应用了双重编码。因此,我认为您应该从代码删除编码步骤:

from google.cloud import vision
import base64
client = vision.ImageAnnotatorClient()
image_path ='8720911950_91828a2aeb_b.jpg'
with open(image_path, 'rb') as image:
    content = image.read()
    response = client.annotate_image({'image': {'content': content}, 'features': [{'type': vision.enums.Feature.Type.LABEL_DETECTION}],})
    print(response)
python 2022/1/1 18:36:50 有306人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶