Home > OS >  AWS Rekognition Validation Error when trying to use RecognizeCelebrities
AWS Rekognition Validation Error when trying to use RecognizeCelebrities

Time:01-28

I have been trying to experiment with the AWS Rekognition but I have been encountering a really weird bug. I keep getting a validation error but I have no Idea why.

Here is my code:

  const client = new RekognitionClient({
    region: "us-east-2",
    credentials: {
      accessKeyId: process.env.AWS_ACCESS_KEY_ID,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    },
  });
  const image = await imageToBase64("../tests/photos/testImage.jpg");
  // const image = fs.readFileSync("../tests/photos/testImage.jpg");
  // console.log(image);
  const params = {
    Image: {
      Bytes: image,
    },
  };
  console.log(JSON.stringify(params));
  const command = new RecognizeCelebritiesCommand(JSON.stringify(params));
  console.log(command);
  try {
    const data = await client.send(command);
  } catch (e) {
    console.log(e.message);
  }

Here is the console log of the command variable:

RecognizeCelebritiesCommand {
  middlewareStack: {
    add: [Function: add],
    addRelativeTo: [Function: addRelativeTo],
    clone: [Function: clone],
    use: [Function: use],
    remove: [Function: remove],
    removeByTag: [Function: removeByTag],
    concat: [Function: concat],
    applyToStack: [Function: cloneTo],
    identify: [Function: identify],
    resolve: [Function: resolve]
  },
  input: '{"Image":{"Bytes":"/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAFCAecDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc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KEtUfKdynlyMvcGrOh3Qtb6NyejZp2vRiG8k2 tZayFTmvnpaM9ZH2V8I/iTBZwwq0gxgc5r2e8 MGmrYgPMucetfnRpniy60vHlSED61dn JGpzY3ytge9JTsdC2PrPxd8RbbULhvKcHnsa5ubxlcxx/upGB9QcV4B4c8ayT3o89iefWvY9DuLXVLUAlQ2OM1zylzPU9KjrHQbb/ABt1vwvqhlW5kMfQqxJr0G0/bTNjpoLo7zAfd7V8/eP4RHM 3jFeVXbyLIfmJGavRq5wVeaMrNnr3xG/aU1jxnqE7MgWBmyFrze78ZXN5ksu3Nc 3zdaFWrUjmN/TtWfztxbnNeo E/FHCqWOceteO6dA80mErrtMs7qyYSYOKiT0NqN ZHsd9ff2hbY 9xXnOvaWJX27c5NamlaszKAzEH0qYMlxexgjOTXEr8x61azgUfDvgGS7kQhTXr3h/wI1na5KHOOldF8N/DcNwkbMnUV7JJ4OiGl7kXnbX1uHp 4mfI1pPnsfNfiG1a1VYz1orq/F/h9/thHGAaKctyEfG2tXjzSHJ/WsdY2fOBV1lN1JgGuh8P FXvmGFOPpXzHMon0Kpyqu6OesLeRZASpwa gvgTcz2GoRyxZUg9a4VPBrIQApI leqfDPSZNMmiAUj6iuOvWtGyOzD4Zqa5j7M8H/ECW10 FZJcHHU1rX3xMTax8zdXkmk21xcWqcbRirkmjyNyc15Wsj6FRSWh02ofEJ7hm2cLWd/wmj pNYc2nmFcFfxqW18PtMm4DiupPSxlbUbr/AImN3avuOe1eKeMLe'... 26614 more characters
}

I am getting "validation error detected: Value null at 'image' failed to satisfy constraint: Member must not be null" when I run this code. I have tried passing the image in as a bitmap and base64 string to no avail. The image that I am using is less than 5Mbs and is a jpg file.

Thanks!

CodePudding user response:

Look at the JS rekognition example in AWS Github. This shows you how to successfully pass an image to a rekognition operation using the AWS SDK for JavaScript version 3 API.

See:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/rekognition/estimate-age-example/src/estimate-age.js

  • Related