翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
SearchUsersByImage
は、指定されたイメージ内で検出された最大の顔に一致するユーザーの、指定された CollectionID を、コレクション内で検索します。デフォルトでは、SearchUsersByImage は類似度スコアが 80% を超える UserID を返します。類似度は、UserID が、指定されたイメージで検出された最大の顔とどの程度一致しているかを示します。複数の UserID が返された場合、類似度スコアが高いものから順に一覧表示されます。必要に応じて、UserMatchThreshold を使用して別の値を指定できます。詳細については、「コレクション内のユーザーの管理」を参照してください。
イメージでユーザーを検索するには (SDK)
-
まだ実行していない場合:
-
AmazonRekognitionFullAccess
アクセス権限を持つユーザーを作成または更新します。詳細については、「ステップ 1: AWS アカウントを設定してユーザーを作成する」を参照してください。 -
および AWS SDKs をインストール AWS CLI して設定します。詳細については、「ステップ 2: AWS CLI と AWS SDKsを設定する」を参照してください。
-
-
以下の例を使用して、
SearchUsersByImage
オペレーションを呼び出します。この Java の例では、
SearchUsersByImage
オペレーションを使用して、入力されたイメージに基づきコレクション内のユーザーを検索します。import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.Image; import com.amazonaws.services.rekognition.model.S3Object; import com.amazonaws.services.rekognition.model.SearchUsersByImageRequest; import com.amazonaws.services.rekognition.model.SearchUsersByImageResult; import com.amazonaws.services.rekognition.model.UserMatch; public class SearchUsersByImage { //Replace bucket, collectionId and photo with your values. public static final String collectionId = "MyCollection"; public static final String s3Bucket = "bucket"; public static final String s3PhotoFileKey = "input.jpg"; public static void main(String[] args) throws Exception { AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); // Get an image object from S3 bucket. Image image = new Image() .withS3Object(new S3Object() .withBucket(s3Bucket) .withName(s3PhotoFileKey)); // Search collection for users similar to the largest face in the image. SearchUsersByImageRequest request = new SearchUsersByImageRequest() .withCollectionId(collectionId) .withImage(image) .withUserMatchThreshold(70F) .withMaxUsers(2); SearchUsersByImageResult result = rekognitionClient.searchUsersByImage(request); System.out.println("Printing search result with matched user and similarity score"); for (UserMatch match: result.getUserMatches()) { System.out.println(match.getUser().getUserId() + " with similarity score " + match.getSimilarity()); } } }
SearchUsersByImage オペレーションのリクエスト
SearchUsersByImage
のリクエストには、検索先のコレクションとソースイメージの場所が含まれます。次の例では、ソースイメージは Amazon S3 バケット (S3Object
) に保存されています。また、返されるユーザーの最大数 (MaxUsers
) と、ユーザーを返すために一致する必要がある最小限の信頼度 (UserMatchThreshold
) も指定されています。
{
"CollectionId": "MyCollection",
"Image": {
"S3Object": {
"Bucket": "bucket",
"Name": "input.jpg"
}
},
"MaxUsers": 2,
"UserMatchThreshold": 99
}
SearchUsersByImage オペレーションのレスポンス
SearchUsersByImage
のレスポンスには SearchedFace
の FaceDetail
オブジェクトと、UserId
、Similarity
、UserStatus
の UserMatches のリストがそれぞれ含まれます。入力したイメージに複数の顔が含まれている場合は、UnsearchedFaces のリストも返されます。
{
"SearchedFace": {
"FaceDetail": {
"BoundingBox": {
"Width": 0.23692893981933594,
"Top": 0.19235000014305115,
"Left": 0.39177176356315613,
"Height": 0.5437348484992981
}
}
},
"UserMatches": [
{
"User": {
"UserId": "demoUser1",
"UserStatus": "ACTIVE"
},
"Similarity": 100.0
},
{
"User": {
"UserId": "demoUser2",
"UserStatus": "ACTIVE"
},
"Similarity": 99.97946166992188
}
],
"FaceModelVersion": "6",
"UnsearchedFaces": [
{
"FaceDetails": {
"BoundingBox": {
"Width": 0.031677018851041794,
"Top": 0.5593535900115967,
"Left": 0.6102562546730042,
"Height": 0.0682177022099495
}
},
"Reasons": [
"FACE_NOT_LARGEST"
]
},
{
"FaceDetails": {
"BoundingBox": {
"Width": 0.03254449740052223,
"Top": 0.6080358028411865,
"Left": 0.516062319278717,
"Height": 0.06347997486591339
}
},
"Reasons": [
"FACE_NOT_LARGEST"
]
}
]
}