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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ