如果我上传了较小的较低分辨率图像,我得到了aws rekognition无效参数异常。
看到以下错误
https://rekognition.us-west-2.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"} InvalidImageFormatException (client): Request has invalid image format - {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"}' GuzzleHttp\Exception\ClientException: Client error: `POST https://rekognition.us-west-2.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"} in /var/www/vhosts/harvest.io.farm/aws/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111 Stack trace: #0 /var/www/vhosts/harvest.io.farm/aws/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(Guz in /var/www/vhosts/harvest.io.farm/aws/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 192
我的代码是
$result = $recognizationClient->indexFaces([
'CollectionId' => getCollectionName( $txtCID ), // REQUIRED
'Image' => [ // REQUIRED
'S3Object' => [
'Bucket' => $bucket,
'Name' => $actual_image_name
],
],
]);
答案 0 :(得分:0)
当indexFaces无法检测到任何面孔时,抛出此异常。这可能是图片很小且模糊不清,但在其他情况下,例如没有真实面孔的情况。您可以尝试先运行DetectFaces并检查响应。 与此类似:
$is_face_detected = $aws_rekognition_client->detectFaces([
'Image' => [
'S3Object' => [
'Bucket' => $bucket,
'Name' => $actual_image_name
]
]
]);
if (!empty($is_face_detected['FaceDetails'])) {
$result = $recognizationClient->indexFaces([
'CollectionId' => getCollectionName( $txtCID )
'Image' => [
'S3Object' => [
'Bucket' => $bucket,
'Name' => $actual_image_name
],
],
]);
} else {
// perform notification, etc.
}
您可以在此处找到有关“检测面部”的更多信息: https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html