Показывает, как использовать объект Aws\Rekognition\RekognitionClient для вызова операций сравнения лиц. PHP:
Использовать клиент распознавания
require 'vendor/aws/aws-autoloader.php';
use Aws\Rekognition\RekognitionClient;
Учетные данные для доступа к параметру кода сервиса AWS
$credentials = new Aws\Credentials\Credentials('{AWS access key ID}', '{AWS secret access key}');
Получите доступ к распознаванию
$rekognitionClient = RekognitionClient::factory(array(
'region' => "us-east-1",
'version' => 'latest',
'credentials' => $credentials
));
Вызов функции сравнения лиц
$compareFaceResults= $rekognitionClient->compareFaces([
'SimilarityThreshold' => 80,
'SourceImage' => [
'Bytes' => file_get_contents("SourceImage.jpg")
],
'TargetImage' => [
'Bytes' => file_get_contents("TargetImage.jpg")
],
]);
Ответ на данные JSON
$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
Примечание. Пример результатов AWS: –
{
"SourceImageFace": {
"BoundingBox": {
"Width": 0.4662500023841858,
"Height": 0.6998124122619629,
"Left": 0.5024999976158142,
"Top": 0.09849905967712402
},
"Confidence": 99.99332427978516
},
"FaceMatches": [
{
"Similarity": 93,
"Face": {
"BoundingBox": {
"Width": 0.23999999463558197,
"Height": 0.3602251410484314,
"Left": 0.43937501311302185,
"Top": 0.17823639512062073
},
"Confidence": 99.99273681640625,
"Landmarks": [
{
"Type": "eyeLeft",
"X": 0.5512950420379639,
"Y": 0.32593753933906555
}
....................
....................
],
"Pose": {
"Roll": 13.300010681152344,
"Yaw": 48.84736251831055,
"Pitch": -11.894044876098633
},
"Quality": {
"Brightness": 45.3167610168457,
"Sharpness": 99.99671173095703
}
}
},
"UnmatchedFaces": []
}
Источник : Как использовать AWS Rekognition для Сравните Face в PHP
person
Pranavan SP
schedule
07.01.2018