3

I am trying to use Amazon Rekognition Service with Node.js,
I uploaded a face image to S3 service in a bucket with a sample program and now I want to detect face with Node.js

The code is as below

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Load credentials and set region from JSON file
AWS.config.loadFromPath('./config.json');

var rekognition = new AWS.Rekognition({apiVersion: '2016-06-27'});
var s3 = new AWS.S3({apiVersion: '2006-03-01'});

/* This operation detects faces in an image stored in an AWS S3 bucket. */

var params = {
Image: {
   S3Object: {
   Bucket: "rekognitionfortesting", 
   Name: "face1.jpeg"
  }
 },

};
rekognition.detectFaces(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else     console.log(data);           // successful response

});

I coudn't get true data, this is the response I get:

enter image description here

[Object] is written. Normally it should give a response like below.

data = {
    FaceDetails: [
       {
      BoundingBox: {
       Height: 0.18000000715255737, 
       Left: 0.5555555820465088, 
       Top: 0.33666667342185974, 
       Width: 0.23999999463558197
      }, 
      Confidence: 100, 
      Landmarks: [
         {
        Type: "EYE_LEFT", 
        X: 0.6394737362861633, 
        Y: 0.40819624066352844
       }, 
         {
        Type: "EYE_RIGHT", 
        X: 0.7266660928726196, 
        Y: 0.41039225459098816
       }, 
         {
        Type: "NOSE_LEFT", 
        X: 0.6912462115287781, 
        Y: 0.44240960478782654
       }, 
         {
        Type: "MOUTH_DOWN", 
        X: 0.6306198239326477, 
        Y: 0.46700039505958557
       }, 
         {
        Type: "MOUTH_UP", 
        X: 0.7215608954429626, 
        Y: 0.47114261984825134
       }
      ], 
      Pose: {
       Pitch: 4.050806522369385, 
       Roll: 0.9950747489929199, 
       Yaw: 13.693790435791016
      }, 
      Quality: {
       Brightness: 37.60169982910156, 
       Sharpness: 80
      }
     }
    ], 
    OrientationCorrection: "ROTATE_0"
   }
   */
 });

How can I get the face data?

imTachu
  • 3,759
  • 4
  • 29
  • 56
ays
  • 39
  • 1
  • 3

4 Answers4

4

Your console.log("data") is printing the object information correctly. What you need to do is stringify your object model this way:

console.log(JSON.stringify(data, null, '\t'));

Hope this helps.

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
bert
  • 76
  • 5
0

The reason is that console.log output the variable with a limited depth. So it won't display the members but rather only their type. You can still access the result object in your code by doing something like:

data.FaceDetails[0].BoundingBox.height
...

You can find more information about how to increase the depth of the console.log here.

Community
  • 1
  • 1
255kb - Mockoon
  • 6,657
  • 2
  • 22
  • 29
0

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Rekognition.html#compareFaces-property

Here it is explained properly, it is from amazon.

Mohammed mansoor
  • 743
  • 3
  • 11
  • 18
0

In your scenario make Attributes to ALL also it accepts two params which DEFAULT|ALL

  Image:{
        S3Object:{
            Bucket:"xxxxxxxxxx",
            Name:"xxxxxxxxxxx"
        }
    },
    "Attributes":["ALL"]