har*_*han 6 python amazon-web-services boto3 amazon-rekognition
我正在尝试按照 AWS 文档中的说明,通过 Python boto3 使用 AWS Rekognition 来比较人脸。
我的 API 调用是:
client = boto3.client('rekognition', aws_access_key_id=key, aws_secret_access_key=secret, region_name=region )
source_bytes = open('source.jpg', 'rb')
target_bytes = open('target.jpg', 'rb')
response = client.compare_faces(
SourceImage = {
'Bytes':bytearray(source_bytes.read())
},
TargetImage = {
'Bytes':bytearray(target_bytes.read())
},
SimilarityThreshold = SIMILARITY_THRESHOLD
)
source_image.close()
target_image.close()
Run Code Online (Sandbox Code Playgroud)
但每次运行这个程序时,我都会收到以下错误:
botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the CompareFaces operation: Request has Invalid Parameters
Run Code Online (Sandbox Code Playgroud)
我已经正确指定了秘密、密钥、区域和阈值。如何清除此错误并使请求调用正常工作?
对于那些仍在寻找答案的人,
我遇到了同样的问题,同时,@mohanbabu 指出了官方文档中应该包含哪些内容compare_faces,我意识到在和compare_faces中查找面孔。我通过首先使用 aws 检测人脸并将检测到的人脸传递给 来确认这一点。SourceImageTargetImagedetect_facescompare_faces
compare_facesdetect_faces当检测到的人脸有点模糊时,几乎总是失败。
因此,如果你的任何一个SourceImage或任何一个TargetImage被紧紧剪裁以面对AND那张脸不是立即明显的,compare_faces那么总结就会失败。
可能还有其他原因,但这个观察对我有用。
前任:
在上图中,你可以相当自信地说中间有一张脸
但,
现在,不那么明显了。
至少这对我来说是原因,检查你的图像你应该知道。
| 归档时间: |
|
| 查看次数: |
3935 次 |
| 最近记录: |