$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 并将其作为源图像发送。它会引发一个大错误。我在做什么错误的?