简体   繁体   中英

AWS S3 putobject and after DetectFaces with Rekognition

Iam doing a project with nodejs and aws.

I am using WebRTC and taking photo.

After i am taking photos base64 data and posting nodejs and i am putting it my aws console and i am using it for detectfaces but its giving error.

But i am adding photo from my aws console manually detect faces not giving a error.

My codes here : MY WEBCAM JS : this is giving a base64 for me.

> drawImage(video, 0, 0, canvas.width, canvas.height);
>      var data = canvas.toDataURL('image/jpeg');
>       photo.setAttribute('src', data);
>       console.log(data);

and i am trying post with POSTMAN CHROME EXTENSION to my nodejs i can put it well but i can't using a detect faces.

My nodejs :

app.post('/addPhoto', function (req, res) {
 var base64data=new Buffer(req.body.photo.replace(/^data:image\/\w+;base64,/, ""),'base64');
console.log(base64data);
  var params = {Bucket:  "realeyeshomework", Key:"111111111.jpg", Body: base64data};
   s3.putObject(params, function(err, data) {
     if (err)
       console.log(err)
     else{
       console.log("1");

       rekognition.detectFaces( {
 Image: {
        S3Object: {
        Bucket: "realeyeshomework",
        Name:"111111111.jpg"
        }
      },
 Attributes: [
    "ALL"
  ]
}, function(error, response) {
        if (error) console.log(error, error.stack); // an error occurred
        else  res.send(response);
    });
     }
   });
});

MY ERROR : CLICK HERE FOR ERROR

How can i do this please help me i could not fint anything.

Thanks for help.

you set ?

var rekognition = new AWS.Rekognition({apiVersion: '2016-06-27'});

try watch Examples Code

The issue will be with the image. I was facing exactly the same issue but ultimately I found that the image I was using was corrupted. The image was opening correctly in MSPaint but was not being recognized by AWS Rekognition. Try uploading the image directly into the AWS Rekognition console and you will ifnd the same error. More details on this thread : AWS Rekognition Error - InvalidparameterException

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM