Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- declare(strict_types=1);
- namespace AppInfrastructure;
- use AwsRekognitionRekognitionClient;
- class MyComparator
- {
- /**Credentials for access AWS Service code parameter*/
- $credentials = new AwsCredentialsCredentials('{AWS access key ID}',
- '{AWS secret access key}');
- /**Get Rekognition Access*/
- $rekognitionClient = RekognitionClient::factory(array(
- 'region' => "us-east-1",
- 'version' => 'latest',
- 'credentials' => $credentials
- ));
- /**Calling Compare Face function*/
- $compareFaceResults= $rekognitionClient->compareFaces([
- 'SimilarityThreshold' => 1,
- 'SourceImage' => [
- 'Bytes' => file_get_contents("SourceImage.jpg")
- ],
- 'TargetImage' => [
- 'Bytes' => file_get_contents("TargetImage.jpg")
- ],
- ]);
- /**Response to JSON Data*/
- $FaceMatchesResult = $compareFaceResults['FaceMatches'];
- $SimilarityResult = $FaceMatchesResult['Similarity'] //Here You will get similarity
- $sourceImageFace = $compareFaceResults['SourceImageFace']
- $sourceConfidence = $sourceImageFace['Confidence'] // //Here You will get confidence of the picture
Add Comment
Please, Sign In to add comment