我刚刚开始使用 AWS Rekognition,遇到了一个似乎无法解决的问题。
我正在使用检测图像中的文本 - 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:无法连接到端点 - 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')
请注意,Amazon Rekognition 支持的区域为(截至撰写本答案时(:
- 美国东部-2
- 美国东部-1
- 美国西部-2
- AP-东南-2
- AP-东北-1
- 欧盟西部-1