Rekognition will not accept image inputs via Node javascript

0

I've been on this for about 2 days now and it's extremely frustrating.

What I need is to use detectFaces / compareFaces and I want to supply the image files by specifying "Bytes". But after trying all kinds of different encodings and formats, I always end up with an InvalidImageFormatException.

In order to make sure that was actually the problem, I decided to make things simpler and use images from an s3 bucket.

Now, when I detect-faces from the command line, it works! But when I run the same exact thing with my node app, by specifying the bucket file:

{
     Image: {
       S3Object: {
         Bucket: "bucket.test",
         Name: "test.jpg"
       },
     },
     Attributes: ['ALL']
   }

I get an InvalidS3ObjectException ....

And I am quite stumped. Why is it so difficult to provide inputs to Rekognition? Azure just lets you specify image urls and it works no problem.

AWS gives vague error responses and it's unclear what the real problem is.

已提問 2 年前檢視次數 258 次
1 個回答
0

I got things working. I'm not 100% sure what the key difference was but here are the changes I made:

  1. I switched to using the @aws-sdk/client-rekognition node package instead of aws-sdk (which is what the https://docs.aws.amazon.com/rekognition/latest/dg/faces-comparefaces.html docs use).
  2. I realized that calling CompareFaces from node will return an InvalidImageFormatException if one of the images does not contain any faces. How frustrating. I thought this indicated that my image format/data was incorrect. Who knows when my code might have actually been working but I thought it wasn't because of this unclear error. So what I did was catch that error and assume I actually used correct image inputs, but that there essentially is zero matches because one of the images lacks faces.
  3. Made certain I was setting my credentials correctly (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html). I'm pretty sure I already was... but did make some changes in this regard.
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南