Face Recognition with Node.js

August 11, 2011
By Bogomil Shopov
Post Image

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

Bogomil Shopov

I care about privacy, ethical design, and freedom in many aspects. I spend 20+ years working as a web developer and architect, analyst, manager, and product owner/manager in different environments, several countries, and multiple software industries like Healthcare and Hospitality. I wore many hats, and I use the knowledge gathered to optimize the flow of value across complex systems.

One Comment

  • Talvarez

    August 15, 2011 at 5:41 pm

    Haha I wil recommend obviously, Face.js.. that now.. tries to detect smiles.
    And, of course.. I am the developer LOL.


Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.