It’s pretty simple to have a basic face recognition in Node.js using the Face.com API.
Pre-Requirements :
0. You will need apikey and api-secret from face.com. You can obtain them by clicking here.
1. I am using a package called restler to handle REST requests.
npm install restler
Here is the code:
var sys = require('sys'),
api = require('restler');
var api_key = '....';
api_secret = '...'
image_url = 'http://farm6.static.flickr.com/5127/5284942130_ab25c2dafd_b.jpg';
api.get('http://api.face.com/faces/detect.json?api_key='+api_key+'&api_secret='+api_secret+'&urls='+image_url).on('complete', function(data) {
sys.puts("the object gender is: "+ data.photos[0].tags[0].attributes.gender.value + ". I am "+data.photos[0].tags[0].attributes.gender.confidence+" % sure");
sys.puts("The object is smiling: "+ data.photos[0].tags[0].attributes.smiling.value + ". I am "+data.photos[0].tags[0].attributes.smiling.confidence+" % sure");
});
The script returns object gender and is it smiling or not.
Change the picture and be amazed by the results. Click here for the detailed API explanation and more examples.
P.S Here is an interesting project – Face.js
Haha I wil recommend obviously, Face.js.. that now.. tries to detect smiles.
And, of course.. I am the developer LOL.