Face Recognition

This article contains two pieces of Face Recognition code:

HMM Face Recognition

This is my adaptation of the HMM face recognition algorithm described in “Face recognition using an embedded HMM” (1999) paper. The original source was found on the Yahoo OpenCV discussion group. This is an adapted version that stream-lines the process of training and testing of the algorithm.


An HMM approach for face recognitionHidden Markov Models (HMM) have been Hmm Face Recognitionsuccessfully used for speech and action recognition where the data that is to be modeled is one-dimensional. Although attempts to use these one-dimentional HMMs for face recognition have been moderately successful, images are two-dimensional (2-D). Since 2-D HMM’s are too complex for real-time face recognition, in this paper we present a new approach for face recognition using an embedded HMM and compare this approach to the eigenface, method for face recognition, and to other HMM-based methods. Specifically, an embedded HMM has equal or better performance than previous methods, with reduced computational complexity.

Download and Compile

Download and unzip into c: drive root directory. The unpacked directory structure should look like:

++FaceRecognition (Core source for HMM face recognition)
++database (faces database)
++FindFaces (generate training images from video sequence)
++FormatConvert (convert sample images into proper pgm format for training)
++testimages (test images after training)

The face recognition project requires Visual Studio .NET to compile. A linux implementation will be available available on request.

Face Recognition
Batch train face database by running FaceRecognition with no argment ( ”Note: run FaceRecognition in the Visual Studio debug environment, otherwise the program will crash due to some memory bug)
After training you may test the result using the images in the testimages directory. Or you may use a pre-recorded video or directly try from a live video cam stream. See parameter below for different test options. When you run the program in test mode, 3 windows will pop up: the “Video” window is the live cam/test image, “ID” window displays the recognition result, “search” window will display the clipped-out face if testing from live cam stream.

Can either find live video camera or input static image for Face Recognition
Syntax: FaceRecognition [choice [input_image_file_name] | --help]
choice=1: recognize face from static input image,
input_image_filename REQURIED
choice=2: recognize face from pre-recorded video sequence
choice=3: recognize face from LIVE cam
no argument FaceRecognition will run in batch training mode
--help: will display this help message

Adding more people into the face database

  • Record a video sequence of the person sitting in front of the camera, first looking straight, then more head slowly from side to side. This allows the training result to be invariant to head orientation changes
  • Run the FindFaces program to generate a sequence of training face images from the recorded video sequence
  • Run the FormatConvert program to convert the training images into the proper pgm format (need to be in the gray scale p5 format).
  • Place the result training into the database directory.
  • Run FaceRecognition without argument to train, WAIT 5 sec, and DONE!

Ravela Face Algorithm
The C++ implementation of the Ravela Face Algorithm can be found at the LPR wiki (LPR wiki access required)

Related paper:

One Response to “Face Recognition”

Leave a Reply