I want to compare two photos. When I connected to AWS I try to connect to AmazonRekognitionClient
:
CompareFacesResult result = new
AmazonRekognitionClient(credentialsProvider).compareFaces(request);
But have this error:
Caused by: com.amazonaws.services.rekognition.model.AccessDeniedException: User: arn:aws:sts::475877890857:assumed-role/wsirstpp-20181028230251-unauthRole/CognitoIdentityCredentials is not authorized to perform: rekognition:CompareFaces (Service: AmazonRekognition; Status Code: 400; Error Code: AccessDeniedException; Request ID: 7f665a07-db54-11e8-8773-2de830a9e39f)
Full code for getting information about photos:
ByteBuffer image1 = ByteBuffer.wrap(imageSource);
ByteBuffer image2 = ByteBuffer.wrap(imageTarget);
CompareFacesRequest request = new CompareFacesRequest()
.withSourceImage(new Image().withBytes(image1))
.withTargetImage(new Image().withBytes(image2))
.withSimilarityThreshold(70 F);
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
context,
"us-east-2:My_pool_Id", // Identity pool ID
Regions.US_EAST_2 // Region
);
CompareFacesResult result = new AmazonRekognitionClient(credentialsProvider).compareFaces(request);
List < CompareFacesMatch > faceMatches = result.getFaceMatches();
for (CompareFacesMatch match: faceMatches) {
Float similarity = match.getSimilarity();
Log.d(TAG, "run: similarity:" + similarity.toString());
}
What is wrong? What I did wrong in this code?
The cause was in Cognito rules. Firstly need to create a rule and then edit rule