Open justinjoy opened 5 years ago
ID로 식별한 얼굴과 일치하는 얼굴에 대한 정보를 표시. collectionID의 값을, 원하는 얼굴이 있는 모음으로 변경합니다. faceId의 값을, 찾으려는 얼굴의 식별자로 변경합니다.
예시코드
//Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.)
package aws.example.rekognition.image;
import com.amazonaws.services.rekognition.AmazonRekognition;
import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.amazonaws.services.rekognition.model.FaceMatch;
import com.amazonaws.services.rekognition.model.SearchFacesRequest;
import com.amazonaws.services.rekognition.model.SearchFacesResult;
import java.util.List;
public class SearchFaceMatchingIdCollection {
public static final String collectionId = "MyCollection";
public static final String faceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
public static void main(String[] args) throws Exception {
AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
ObjectMapper objectMapper = new ObjectMapper();
// Search collection for faces matching the face id.
SearchFacesRequest searchFacesRequest = new SearchFacesRequest()
.withCollectionId(collectionId)
.withFaceId(faceId)
.withFaceMatchThreshold(70F)
.withMaxFaces(2);
SearchFacesResult searchFacesByIdResult =
rekognitionClient.searchFaces(searchFacesRequest);
System.out.println("Face matching faceId " + faceId);
List < FaceMatch > faceImageMatches = searchFacesByIdResult.getFaceMatches();
for (FaceMatch face: faceImageMatches) {
System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(face));
System.out.println();
}
}
}
AWS rekognition document