Face Recognition with Ruby

———— DEPRECATED ————-

This post is no longer valid, since was acquired by facebook and doesn’t provide an open API anymore.

We all know that we can search web pages for text, but there are services that go beyond a simple text search and use features like location and or image data. The hurdle relying on these features is that normally the end users have to enter manually the appropriate data. When was the last time you tagged people Facebook? Now think what if we have a system that helps us to automate the process of face recognition. Lets understand face recognition and how you can use it with Ruby.

What is Face Recognition?

Face Recognition uses feature extraction from facial points (like detecting where the eyes, nose, mouth etc are) within images or videos to recognize people. As you can image such a task isn’t trivial and requires a lot of know how. But the good news are that facial recognition just got a lot easier for developers to include in their applications., a company that specializes in facial recognition, opened its platform APIs, allowing developers to integrate its facial recognition technology in third-party websites and applications.

Developers Get Facial Recognition API from

The API uses REST-like interface. This means that all calls to the API are made over the Internet, using HTTP GET and POST requests to the API server. Hence, any programming language that supports HTTP can be used to communicate with the service. has some common libraries to get you started.

How to use it with Ruby ?

Step 1: Get your API Key from Don’t forget to add Facebook API and Secret Key as well as Twitter API Key And Secret Key. Keep them handy to use in your application.

Step 2: To use Face Recogonition API in Ruby we have to install the gem called face.
sudo gem install face

Step 3: Now using api_key and api_secret, you can access get_client method of API.
>> client = Face.get_client(:api_key => ‘your_api_key’, :api_secret => ‘your_api_secret’)

Face Detection using Face gem in Ruby

Face gem provides three different ways to detect faces in an image.

  1. Detect Faces with Urls
  2. Detect Faces with Raw image data
  3. Detect and Recognize faces with user auth

Lets understand with examples.

Detect Faces with Urls:

Suppose we want to detect face in the image located at this url. You will have to use faces_detect method as given below.

>>client.faces_detect(:urls => [''])

It will return photo detection output in the following way. Notice that you here you get face related information in a JSON format.

Detect Faces with Raw image data:

To detect faces from Raw image data, you will have to use following.

Detect and Recognize faces with user auth:

>> client.twitter_credentials = { :twitter_username => 'twitter_screen_name', :twitter_password => 'twitter_password' }
>> client.faces_recognize(:urls => [''], :uids => ['uiicor']) # will make request with twitter credentials

Hereby we are trying to recognize face with twitter credentials.

First we will have to initialize twitter credentials like this:

Step 2: To send the face recoginze request , write in the following way.

Note that uid is the id of the user on twitter.


The face gem provides facilty to detect faces from multi or single face images. Face gem is still under development. You can test it on site. To get a feel for what is possible with the API you can browse some of the online examples, complete with source code, or play in the API sandbox. The API has some decent documentation for those looking to dig deeper into the service, although the forums are fairly quiet at the moment.

Published by

Helmut M. Juskewycz

I like and create awesome Software! Besides developing, I am interested in a lot of things. Startups, Business, Gaming, Sports, Movies, just to name a view. Founder of LingoHub.

  • Cristian


    if you are interested in an open-source alternative, try (sourcecode on github)

    To detect faces in image with the ruby gem at

    [code]require ‘rdetectionapi’

    Best regards,

  • Juan Maiz

    is there any code samples with private namespaces, detect, train and recognize…?

  • Shanmukhakatta

    Thanks this article.Exactly I want this gem.

  • Honory

    Any way you can deprecate this article, as isn’t opening their service external anymore?

  • hjuskewycz

    I deprecated the article. thanks for pointing out that doesn’t exist anymore