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/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/

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.


10 thoughts on “Face Recognition in Processing and Ubuntu 11.10

  1. Pingback: The pest of having a 64 bit Linux laptop and OpenCV | In my humble opinion…

  2. Pingback: Final Post: Gamex and Faces in Baroque Paintings | In my humble opinion…

  3. 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

    • 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.

    • I don’t have Ubuntu 12.04, but I can tell you that in Ubuntu 13.10, the libraries are the corresponding to 2.4:

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

      If not, you can do:

      1. sudo apt-get update

      2. Then write “sudo apt-get install libcv” and press the Tab key a couple of times. I will display the available libraries


  4. hello..
    my environment is ubuntu12.04LTS 32bit.
    i followed many tutorial in google. but, finally all is failed…
    at first time, i started to processing your post and my purpose also face detection and face recognition.
    can you help me processing all progress… plz

    error also too many.
    if, i use processing 1.5.1 — errlink java
    else if, i use processing 2.1.1 —
    “A library relies on native code that’s not available.
    Or only works properly when the sketch is run as a 64-bit application.”
    so i think go to 64bit OS. but At 64bit ubuntu 11.10.
    error message said
    “A library relies on native code that’s not available.
    Or only works properly when the sketch is run as a 32-bit application.”
    i confused. T.T help me

    • I am really sorry for the super late. Seen your comment reminds me a problem with 64bit or 32bit and right now it is difficult to remember. It just doesn’t work on one of them. I did this a few years ago 🙁

      I might be wrong but I think processing runs on top of java. So, you ll need to install java as well. In this case, run it on ubuntu 32bits because your related error appears on that version

Leave a reply