Nice to See You – Recognizing Faces using Face.com
Nice to See You – Recognizing Faces using Face.com
Last month, and to a small amount of fanfare, Face.com released an API for performing facial recognition on an arbitrary set of images. Most exciting is its support for recognizing friends on Facebook and Twitter.
Kami has graciously written a Python library for Face.com and released it on github.
Here is some sample code for taking a photo on a Mac, recognizing the face, and then cross-referencing Facebook for the user’s info.
client = face_client.FaceClient(API_KEY)
client.set_facebook_credentials(session=FB_SESSION_KEY, user=FB_USER_ID)
def recognize():
os.system("/Applications/isightcapture /tmp/pic.jpg")
result = client.faces_recognize(file='/tmp/pic.jpg', uids="friends@facebook.com")
uid = result['photos'][0]['tags'][0]['uids'][0]['uid']
uid = uid.replace("@facebook.com", "")
fb_result = get("http://graph.facebook.com/" + uid)
fb_result = simplejson.loads(fb_result)
print "Hello, %s" % (fb_result['name'])
The recognition abilities of Face.com are a little hit-or-miss, but the possibilities for such a service are exciting. Imagine mounting a camera on your door which would recognize people who enter your home. Now your music selection is dynamically changed given that person’s music preferences. Add Hunch’s Facebook integration and you’ve got some serious potential for cool applications and mashups.
Errata
- iSightCapture for easy access to the Macbook camera
- Facebook infinite session keys, available byGoing to http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY with your application’s API_KEY, which will return a special codeCalling auth.getSession with the special code in the Facebook Test Console
- Going to http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY with your application’s API_KEY, which will return a special code
- Calling auth.getSession with the special code in the Facebook Test Console