使用变量不工作的Aws重新认知传递图像

时间:2017-10-01 05:02:21

标签: php json amazon-web-services amazon-rekognition

$rekognition = new RekognitionClient([
'version' => 'latest',
'region'  => 'us-west-2',
'credentials' => [
    'key'    => '....................',
    'secret' => '....................'
]
]);




$source2=json_encode($source);
echo $source2;

$result3=$rekognition->compareFaces([
'SimilarityThreshold' => 70.05,
'SourceImage' => [ 

    'S3Object' => [
        'Bucket' => 'krishrekog',
        'Name' => "david.jpg",             //Here is the problem

    ],
],
'TargetImage' => [ 

    'S3Object' => [
        'Bucket' => 'krishrekog',
        'Name' => 'target.jpg',

    ],
],
]);

$similar=0;



 foreach($result3['FaceMatches'] as $d){
   $similar=$d['Similarity']."<br>";
} 

if($similar>75){
echo "Matching faces!!";
}
else{
echo "Not Matching Faces!!";
}

在上面的代码中,如果我提供源图像为david.jpg它将没有错误,但如果我将图像名称存储在变量中并使用json_encode并将其作为源图像发送。它会引发一个很大的错误。我做错了吗?

0 个答案:

没有答案