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.

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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠