【发布时间】:2021-10-28 03:12:33
【问题描述】:
这是我在尝试对 s3 存储桶中的图像运行文本检测时看到的错误:botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectText operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
bucket -> 存储桶的名称 name -> 文件名(例如:123.jpg)
我的代码(python):
client=boto3.client('rekognition', region_name='us-east-1')
print('works till here')
response=client.detect_text(Image={'S3Object':{'Bucket': bucket,'Name': name}})
print('works till here 2')
textDetections=response['TextDetections']
print ('Detected text\n----------')
for text in textDetections:
print ('Detected text:' + text['DetectedText'])
print ('Confidence: ' + "{:.2f}".format(text['Confidence']) + "%")
print ('Id: {}'.format(text['Id']))
if 'ParentId' in text:
print ('Parent Id: {}'.format(text['ParentId']))
print ('Type:' + text['Type'])
print()
return len(textDetections)
S3 bucket is on global and rekogntion is on us-east-1
【问题讨论】:
-
Amazon S3 存储桶是否也在
us-east-1中? (请注意,存储桶不是全局的——它们位于特定区域中。)尝试使用同一区域中的存储桶。 -
嗨!是的,它也在 us-east-1 中
标签: python amazon-web-services amazon-s3 amazon-rekognition