Note this project was created in 2013 and the Raspberry Pi operating system has since been updated to not be compatible with the RPIO library mentioned below. Use an older version of Raspbian like a wheezy release from 2013 from:

OpenCV Installation

This project depends on the OpenCV computer vision library to perform the face detection and recognition. Unfortunately the current binary version of OpenCV available to install in the Raspbian operating system through apt-get (version 2.3.x) is too old to contain the face recognition algorithms used by this project. However you can download, compile, and install a later version of OpenCV to access the face recognition algorithms.

Note: Compiling OpenCV on the Raspberry Pi will take about 5 hours of mostly unattended time. Make sure you have some time to start the process before proceeding.

First you will need to install OpenCV dependencies before you can compile the code. Connect to your Raspberry Pi in a terminal session and execute the following command:

sudo apt-get update
sudo apt-get install build-essential cmake pkg-config python-dev libgtk2.0-dev libgtk2.0 zlib1g-dev libpng-dev libjpeg-dev libtiff-dev libjasper-dev libavcodec-dev swig unzip

Answer yes to any questions about proceeding and wait for the libraries and dependencies to be installed. You can ignore messages about packages which are already installed.

Next you should download and unpack the OpenCV source code by executing the following commands:


Note that this project was written using OpenCV 2.4.7, although any 2.4.x version of OpenCV should have the necessary face recognition algorithms.

Now change to the directory with the OpenCV source and execute the following cmake command to build the makefile for the project. Note that some of the parameters passed in to the cmake command will disable compiling performance tests and GPU accelerated algorithms in OpenCV. I found removing these from the OpenCV build was necessary to help reduce the compilation time, and successfully compile the project with the low memory available to the Raspberry Pi.

cd opencv-2.4.9

After this command executes you should see details about the build environment and finally a '-- Build files have been written to: ...' message. You might see a warning that the source directory is the same as the binary directory--this warning can be ignored (most cmake projects build inside a subdirectory of the source, but for some reason I couldn't get this to work with OpenCV and built it inside the source directory instead). If you see any other error or warning, make sure the dependencies above were installed and try executing the cmake command again.

Next, compile the project by executing:


This process will take a significant amount of time (about 5 hours), but you can leave it unattended as the code compiles.

Finally, once compilation is complete you can install the compiled OpenCV libraries by executing:

sudo make install

After this step the latest version of OpenCV should be installed on your Raspberry Pi.

Python Dependencies

The code for this project is written in python and has a few dependencies that must be installed. Once connected to your Raspberry Pi in a terminal session, execute the following commands:

sudo apt-get install python-pip
sudo apt-get install python-dev
sudo pip install picamera
sudo pip install rpio

You can ignore any messages about packages which are already installed or up to date. These commands will install the picamera library for access to the Raspberry Pi camera, and the RPIO library for access to the Pi GPIO pins and PWM support (for better servo control with the Pi).

Software Install

After OpenCV and the python dependencies have been installed, download the software for this project from the link below:

Copy the archive to your Raspberry Pi and extract it to a folder.

Continue on to learn about training the face recognition algorithm to recognize your face.

This guide was first published on Jan 24, 2014. It was last updated on Jan 24, 2014.

This page (Software) was last updated on Oct 22, 2021.

Text editor powered by tinymce.