Как я могу получить уверенность при сравнении лиц с помощью amazon rekognition с php?

Я использую Amazon rekognition для сравнения лиц в php (AWS SDK для php Здесь документация.

Код ниже

<?php
require 'aws.phar';

$s3 = new \Aws\Rekognition\RekognitionClient([
'version' => 'latest',
'region'  => 'us-east-1',
]);

$result = $s3->compareFaces([
    'SimilarityThreshold' => 90,
    'SourceImage' => [
          'Bytes' => file_get_contents("https://images.clarin.com/2017/10/23/BkeLV_s6W_930x525.jpg")        
    ],
    'TargetImage' => [
          'Bytes' => file_get_contents("https://pbs.twimg.com/profile_images/653558348273569792/joxg8DZD_400x400.png")
    ],
]);

?>

Я не знаю пхп. Как я могу получить доверие к картинке? Я пробую некоторые вещи, но я не могу получить это.


person Brian M Litwak    schedule 12.12.2017    source источник


Ответы (1)


Показывает, как использовать объект 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