Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: a7350e7941
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (45 sloc) 3.31 KB


This project implements the Eigenfaces method as described in: Turk and Pentland, "Eigenfaces for recognition.", Journal of Cognitive Neuroscience 3 (1991), 71–86.

Building the Project

This project comes as a CMake project, so compiling the project is as easy as writing (assuming you are in this folder):

philipp@mango:~/some/dir/eigenfaces$ mkdir build
philipp@mango:~/some/dir/eigenfaces$ cd build
philipp@mango:~/some/dir/eigenfaces/build$ cmake ..
philipp@mango:~/some/dir/eigenfaces/build$ make
philipp@mango:~/some/dir/eigenfaces/build$ ./eigenfaces filename.ext

And if you are in Windows using MinGW it may look like this:

C:\some\dir\eigenfaces> mkdir build
C:\some\dir\eigenfaces> cd build
C:\some\dir\eigenfaces\build> cmake -G "MinGW Makefiles" ..
C:\some\dir\eigenfaces\build> mingw32-make
C:\some\dir\eigenfaces\build> eigenfaces.exe filename.ext

You probably have to set the OpenCV_DIR variable if it wasn't added by your installation, see Line 5 in the CMakeLists.txt how to do this. If you have problems working with CMake or installing OpenCV, you probably want to read my guide on Face Recognition with OpenCV2.

Using the Project

The project comes with an example, please have a look at the main.cpp on how to use the classes. You need some data to make the examples work, sorry but I really can't include those face databases in my repository. I have thoroughly commented the code and reworked it lately, to make its usage simpler. So if anything regarding the classes is unclear, please read the comments.

In the example I use a CSV file to read in the data, it's the easiest solution I can think of right now. However, if you know a simpler solution please ping me about it. Basically all the CSV file needs to contain are lines composed of a filename followed by a ; followed by the label (as integer number), making up a line like this: /path/to/image.ext;0.

Think of the label as the subject (the person) this image belongs to, so same subjects (persons) should have the same label. An example CSV file for the AT&T Facedatabase is given here, which looks like this (assuming I've extracted the database to /home/philipp/facerec/data/at, file is without ... of course):


Once you have a CSV file with valid filenames and labels, you can run the demo by simply starting the demo with the path to the CSV file as parameter:

./eigenfaces /path/to/your/csvfile.ext

Or if you are in Windows:

eigenfaces.exe /path/to/your/csvfile.ext


All code is put under a BSD license, so feel free to use it for your projects.

Jump to Line
Something went wrong with that request. Please try again.