-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (36 loc) · 1.07 KB
/
index.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
42
var fs = require('fs')
var Vision = require('@google-cloud/vision')
require('dotenv').config()
var vision = Vision()
function detectFaces (inputFile, callback) {
// Make a call to the Vision API to detect the faces
const request = { source: { filename: inputFile } };
vision.faceDetection(request)
.then((results) => {
const faces = results[0].faceAnnotations;
var numFaces = faces.length;
console.log('Found ' + numFaces + (numFaces === 1 ? ' face' : ' faces'));
callback(null, faces);
})
.catch((err) => {
console.error('ERROR:', err);
callback(err);
});
}
function main (inputFile, outputFile, Canvas, callback) {
outputFile = outputFile || 'out.png';
detectFaces(inputFile, (err, faces) => {
if (err) {
return callback(err);
}
// console.log('Highlighting...');
// highlightFaces(inputFile, faces, outputFile, Canvas, (err) => {
// if (err) {
// return callback(err);
// }
// console.log('Finished!');
// callback(null, faces);
// });
});
}
main('./teste-de-ai.jpg')