-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexFaces.js
41 lines (33 loc) · 921 Bytes
/
indexFaces.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const Aws= require('./index')
const fs = require('fs')
function base64Encode(file) {
var body = fs.readFileSync(file, { encoding: null });
// console.log({ body })
return body.toString('base64');
}
const test = async () => {
try{
// const contents = await fs.readFile('images/1.jpg', {encoding: 'base64'});
const contents = base64Encode('images/1.jpg')
// console.log(contents)
const data = await Aws.rekognition.indexFaces({
CollectionId: 'test1', /* required */
Image: { /* required */
Bytes: Buffer.from(contents, 'base64')
// Bytes: fs.readFileSync('images/1.jpg')
},
ExternalImageId: 'something',
DetectionAttributes: ['DEFAULT'],
MaxFaces: 1,
QualityFilter: 'AUTO'
}).promise()
console.log(data)
console.log(data.FaceRecords[0])
}catch(e){
console.log(e)
}
}
test().then((data) => {
// console.log(err)
// console.log(data)
})