C/C++‎ > ‎

OpenCV Facerecog

This is the first version of a face recognition program based on the example program in the article series of Robin Hewitt:
http://www.cognotics.com/opencv/servo_2007_series/index.html

It's now also on SourceForge:
https://sourceforge.net/projects/opencvfacerecog/

Original

It's using the OpenCV lib to detect and recognize faces in an image.
Just extract opencv-facerecog.tar.gz and run run.sh. It will compile (needs libcv-dev, libcvaux-dev, libhighgui-dev, libboost-dev and libboost-filesystem-dev) and run an example:
 $ ./opencv-facerecog Mona.jpg
 Mona


Detected face, which is then recognized as "Mona"


Further explanation:
The program refers to its face database file (facedata.xml), which is stored in ~/.opencv-facerecog.
To add a person to the database, you need to create a subfolder with the person's name and place at least one 100x100px portrait in it.
Then you need to recreate the faces database with
 $ ./opencv-facerecog -b
Now the person can be recognized by the program.

To get a 100x100px portrait from any image, you can run the program in detection mode:
 $ ./opencv-facerecog -d example.jpg
It outputs all faces which have been found as example_crop_#.pgm, where # is the number of the detected face.
Now you can choose the right one from the output and place it in the person's folder.

If you know that there is only one face in the image, then you can add it directly to the faces folder with:
 $ ./opencv-facerecog -a Mona Mona.jpg
and rebuild the database:
 $ ./opencv-facerecog -b

If you want to know what the program is doing exactly, you have to run it in debug mode:
 $ ./opencv-facerecog -D Mona.jpg
To read the debug output:
 $ tail -f ~/.opencv-facerecog/log.txt

For big images, I recommend to use the resize option, which makes the detection faster and results in less false positives.
If you want to tag your image with the recognized names, I recommend using exiftool:
 $ NAME=$(./opencv-facerecog Mona.jpg | tr '\n' ' '); exiftool -Comment="$NAME" Mona.jpg


Disclaimer:
This is an alpha version, use it for testing purposes only!

Č
ċ
ď
opencv-facerecog.tar.gz
(339k)
El Samuko,
Sep 2, 2012, 3:58 AM
Comments