被告知,我正在尝试使用aw rekognition indexFaces命令将图像上传到“集合”。我成功创建了该集合,但是当我使用IndexFaces命令时,我们遇到以下错误:
Fatal error: Uncaught exception 'Aws\Rekognition\Exception\RekognitionException' with message 'Error executing "IndexFaces" on "https://rekognition.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://rekognition.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Code":"InvalidImageFormatException","Message":"Request has invalid image format (truncated...) InvalidImageFormatException (client): Request has invalid image format - {"__type":"InvalidImageFormatException","Code":"InvalidImageFormatException","Message":"Request has invalid image format"}' GuzzleHttp\Exception\ClientException: Client error: `POST https://rekognition.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Code":"InvalidImageFormatException","Message":"Request has invalid image format (truncated...) in /home/admin/web/mbracecloud.com/public_html/Aws/GuzzleHttp/Exception/RequestException.php:113 Stack trace: #0 /home/admi in /home/admin/web/mbracecloud.com/public_html/Aws/Aws/WrappedHttpHandler.php on line 195
我们正在使用以下代码执行命令
$result = $s3->indexFaces([
'CollectionId' => 'mbrace',
'ExternalImageId' => 'faces',
'Image' => [
'Bytes' => 'images/user.jpg',
],
'MaxFaces' => 1,
'QualityFilter' => 'NONE',
]);
我错在哪里我错了。任何想法如何解决这个问题?
答案 0 :(得分:1)
indexFaces()
API调用需要 Bytes
(用于内嵌图像),或 S3Object
用于指定来自Amazon S3的图像。
如果您是从本地磁盘引用文件,则Bytes
将需要包含图像文件的内容,但是您的代码提供了文件名。这就是为什么它生成InvalidImageFormatException
的原因。
您应该阅读文件的内容,并将其作为字节提供。