我刚刚开始使用 AWS Rekognition,但遇到了一个似乎无法解决的问题。
我正在使用 Detecting Text in an Image - Amazon Rekognition 上提供的 Python 脚本测试该服务如何工作以及如何将其集成到其他应用程序中。
我知道我已经为配置和凭证文件输入了正确的数据,可在此处找到:
~/.aws/credentials
与 S3 等其他服务一样,使用命令行代码也可以正常工作。在提供的代码中(我将在末尾添加它),我指定了正确的存储桶以及我尝试使用的图片的名称。 运行脚本时,在终端上一切正常,直到几秒钟后显示以下错误消息:
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint
URL: "https://rekognition.eu-west-2.amazonaws.com/"
我还尝试了其他几个可用区,例如:
us-east-1, us-west-1, eu-central-1
但是它们都会导致相同的错误。
python - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint - Stack Overflow 中已经讨论了类似的问题。然而,该讨论中提供的解决方案并没有解决我遇到的问题。我将不胜感激任何可以解决此问题的帮助和提示。
import boto3
bucket='bucket'
photo='inputtext.jpg'
client=boto3.client('rekognition')
response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}})
textDetections=response['TextDetections']
print response
print 'Matching faces'
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
最佳答案
你的代码对我来说工作得很好。
我连接到悉尼地区:
client=boto3.client('rekognition',region_name='ap-southeast-2')
请注意supported regions for Amazon Rekognition是(截至撰写此答案时):
- us-east-2
- us-east-1
- us-west-2
- ap-东南-2
- ap-northeast-1
- eu-west-1
关于python - 用于 Rekognition 的端点 URL 的 AWS 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51133277/