-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (37 loc) · 1.26 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
43
44
var express = require('express')
var app = express()
var base64Img = require('base64-img');
var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '10mb'}));
app.post('/', function (req, res) {
let uri = req.body.uri
base64Img.img(uri,'', '1', function(err, filepath) {
console.log('success')
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// const fileName = 'Local image file, e.g. /path/to/image.png';
client
.faceDetection(fileName)
.then(results => {
const faces = results[0].faceAnnotations;
console.log('Faces:');
faces.forEach((face, i) => {
console.log(` Face #${i + 1}:`);
console.log(` Joy: ${face.joyLikelihood}`);
console.log(` Anger: ${face.angerLikelihood}`);
console.log(` Sorrow: ${face.sorrowLikelihood}`);
console.log(` Surprise: ${face.surpriseLikelihood}`);
});
})
.catch(err => {
console.error('ERROR:', err);
});
})
res.send('Hello World')
})
app.listen(3001)