Face Recognition in Processing and Ubuntu 11.10

This post has been moved to robertour.comwhere you can find updates and corrections.

Yesterday, we were playing around with Arduino again. This time Javier and me went to bigger project. A led that turns on when the computer detects a face with the webcam. After solving issues with the Internet connection we divided the work. He went into the task of manipulating the Arduino from Processing and I install the opencv and the respective libraries for processing.

Here are the steps:

1. Install processing.  Just download, uncompress and run.

2. Install opencv. Just open Terminal and execute the next command

sudo apt-get install libcv2.1 libcvaux2.1 libhighgui2.1

3. Find the sketchbook folder. To find the Processing sketchbook location on your computer, open the Preferences window from the Processing application and look for the “Sketchbook location” item at the top. So, for example, my sketchbook was located in /home/roberto/sketches.

4. Find or create the libraries folder. Inside the sketchbook folder (/home/roberto/sketches) there should be another folder called libraries. If you don’t find  it, just create it.

5. Download the library. Click here or look for the last version in the official web page.

6. Uncompress the tar.gz

7. Copy the whole uncompressed folder into the libraries folder. In my case /home/roberto/sketches/libraries. Normally the installation finish here, however it does not work because some of the files are named differently (different version of opencv)

8. Open a Terminal an create the following symbolic links with these commands:

sudo ln -s /usr/lib/libcxcore.so /usr/lib/libcxcore.so.1
sudo ln -s /usr/lib/libcv.so /usr/lib/libcv.so.1
sudo ln -s /usr/lib/libcvaux.so /usr/lib/libcvaux.so.1
sudo ln -s /usr/lib/libml.so /usr/lib/libml.so.1
sudo ln -s /usr/lib/libhighgui.so.2.1 /usr/lib/libhighgui.so.1

9. Open processing and paste the code. Just past this code in the processing window.

10. A small change in the previous code.  Just change this line

opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );    // load the FRONTALFACE description file

for this one

opencv.cascade( "/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" );    // load the FRONTALFACE description file

Actually, I found more than one file. So it probably worth these others files. I just went to try them! The second one is much faster.


11. Run the code and enjoy.

It’s amazing how easily you can run very cool libraries to let your imagination fly. Don’t miss Javier’s blog who is going to post about the whole mini-project with Arduino included during this week.

>>> Please address comments or questions to robertour.com. <<<

This entry was posted in Uncategorized. Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.


  1. Guille Escobar
    Posted April 11, 2013 at 3:47 am | Permalink

    I need help for install processing+opencv in ubuntu 12.04

    • Posted April 17, 2013 at 3:08 pm | Permalink

      32bits or 64bits? I remember I had problems with 64bits and ended up using 32bits.

  2. nicolas
    Posted May 8, 2013 at 5:06 pm | Permalink

    i am having trouble installing open-cv in processing the library doesnt seem to load proparly
    this what i get when i run your code “cannot find class or type named “Rectangle””
    i am running ubuntu 12.10 and processing 2.0b7

    • Posted May 29, 2013 at 9:05 am | Permalink

      I cannot help you that much here. Open-CV library messes with many components of the machine. It is very low level coding.

      It doesn’t seem that your problem is related to Open-CV though. It fails in the line of the rectangle but not when it instantiate the Open-CV class, in the 2nd line of code..

      Try to explore which kind of object is detect returning. The documentation says it doesn’t return anything but that doesn’t make sense since the code is setting a variable.

2 Trackbacks

Skip to toolbar