httpwwwbethedevcom
324329524619168
Loading...

How to use AWS Rekognition to Compare Face in PHP | Face Recognition API

Shows How to use the Aws\Rekognition\RekognitionClient object to call the compare faces operations. Face Recognition API


AWS Rekognition to Compare Face in PHP

Use Recognition Client
require 'vendor/aws/aws-autoloader.php';
use Aws\Rekognition\RekognitionClient;


Credentials for access AWS Service code parameter
$credentials = new Aws\Credentials\Credentials('{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' => 80,
'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


Full Source Code :


Note: AWS Results Example:-



If this code was helpful, I would love to hear from you or If you have any questions please post your comments below.

Thank you!
Rekognition 6101165258861166923

Post a Comment Default Comments Disqus Comments

  1. Hello, I have used your code and it is very helpful for me thanks. I want to compare one image with lots of other images so please suggest me a way to done this. It is very critical part for my project. I have checked this link https://docs.aws.amazon.com/rekognition/latest/dg/faces-comparefaces.html but It cannot give PHP code. So please suggest me PHP code.

    ReplyDelete
  2. You can use 'Collection' feature here. Create a new "collection" in AWS Rek and Insert your face into that collection using "indexFaces" then you can search faces using "Search Face by Image". That's all. if you have doubt don't hesitate to ping me.

    ReplyDelete

emo-but-icon

Home item

Follow by Email

Popular Posts

Random Posts