运行search_faces_by_image

时间:2018-09-10 06:59:34

标签: python amazon-web-services

我对AWS还是很陌生,在过去的一周中,一直关注网站上所有有用的文档。

我目前一直坚持无法在“按图像搜索”之后从Reko集合中提取外部图像ID数据,我只需要能够将该数据放入变量中或打印出来,知道我该怎么做吗?

基本上,这是我的代码:

import boto3

如果名称 ==“ 主要”:

bucket = 'bucketname'
collectionId = 'collectionname'
fileName = 'test.jpg'
threshold = 90
maxFaces = 2

admin = 'test'

targetFile = "%sTarget.jpg" % admin
imageTarget = open(targetFile, 'rb')

client = boto3.client('rekognition')
response = client.search_faces_by_image(CollectionId=collectionId,
                                        Image={'Bytes': imageTarget.read()},
                                        FaceMatchThreshold=threshold,
                                        MaxFaces=maxFaces)

faceMatches = response['FaceMatches']
print ('Matching faces')
for match in faceMatches:
    print ('FaceId:' + match['Face']['FaceId'])
    print ('Similarity: ' + "{:.2f}".format(match['Similarity']) + "%")

最后,我收到:

Matching faces
FaceId:8081ad90-b3bf-47e0-9745-dfb5a530a1a7
Similarity: 96.12%

Process finished with exit code 0

我需要的是外部图像ID,而不是FaceId。

谢谢!

0 个答案:

没有答案