Skip to content

Nycrera/face-plusplus-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

face-plusplus-node

npm version

Face++ /v3 faceplusplus.com API wrapper for Node.js

Installation with npm

$ npm install face-plusplus-node

Configuration

var facepp = require('face-plusplus-node');

Set your API Key / Get your API key and secret at faceplusplus.com (Required)

facepp.setApiKey('API_KEY');

Set your API Secret(Required)

facepp.setApiSecret('API_SECRET');

Set the server (For now only options are 'us' or 'cn')(Optional)

facepp.setServer('cn');

Examples

Face Detection request (pass an image at a URL)

var facepp = require('face-plusplus-node');

  

facepp.setApiKey('API_KEY');

facepp.setApiSecret('API_SECRET');

  

var parameters = {

image_url: 'http://example.com/image.jpg',

return_attributes: 'gender,age,emotion'

};

facepp.post('/detect', parameters, function(err, res) {

console.log(res);

});

Face Detection request (pass an image from the local file system using base64 encoding)

var facepp = require('face-plusplus-node'),

fs = require('fs');

  

facepp.setApiKey('API_KEY');

facepp.setApiSecret('API_SECRET');

  

var parameters = {

return_attributes: 'ethnicity,beauty,eyegaze',

image_base64: fs.readFileSync('./image.jpg').toString('base64')

};

facepp.post('/detect', parameters, function(err, res) {

console.log(res);

});

/*  Output
{ image_id: '/bFHYuZRF3y4pjnqghSNWg==',

request_id: '1535365287,56de0473-9dfe-4c7d-8b1e-f0a818adc0b6',

time_used: 346,

faces:

[ { attributes: [Object],

face_rectangle: [Object],

face_token: 'cd3cb917009c3f8066d721b06255a256' } ] } */

Face Comparison request (pass 2 images from the local file system using base64 encoding)

var facepp = require('face-plusplus-node'),

fs = require('fs');

  

facepp.setApiKey('API_KEY');

facepp.setApiSecret('API_SECRET');

  

var parameters = {

image_base64_1: fs.readFileSync('./image1.jpg').toString('base64'),

image_base64_2: fs.readFileSync('./image2.jpg').toString('base64'),

};

facepp.post('/compare', parameters, function(err, res) {

console.log(res);

});

/*  Output
{ faces1:
[ { face_rectangle: [Object],
face_token: '93819818f4cdc4762caafdf776a347c3' } ],
faces2:
[ { face_rectangle: [Object],
face_token: '9d42ccedd41d19439d866e33b88fab21' } ],
time_used: 445,
thresholds: { '1e-3': 62.327, '1e-5': 73.975, '1e-4': 69.101 },
confidence: 89.485,
image_id2: 'Y74JtlTEfR3Jb/pyoNzT1Q==',
image_id1: '/bFHYuZRF3y4pjnqghSNWg==',
request_id: '1535365156,7db9798d-2c80-4bd0-9773-6e40ef5088c2' } */

You can see all possible parameters and ways to pass image and also compare two faces you can see Face++ Documentation

License

MIT

About

Face Plus Plus /v3 API for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published