Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
ipa_PeopleDetector::FaceRecognizer Class Reference

#include <face_recognizer.h>

Inheritance diagram for ipa_PeopleDetector::FaceRecognizer:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Metrics { EUCLIDEAN, MAHALANOBIS, MAHALANOBISCOSINE }

Public Member Functions

virtual unsigned long addFace (cv::Mat &color_image, cv::Mat &depth_image, cv::Rect &face_bounding_box, cv::Rect &head_bounding_box, std::string label, std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps)
virtual unsigned long deleteFace (int index, std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps)
virtual unsigned long deleteFaces (std::string label, std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps)
 FaceRecognizer (void)
 Constructor.
virtual unsigned long init (std::string data_directory, int norm_size, bool norm_illumination, bool norm_align, bool norm_extreme_illumination, int metric, bool debug, std::vector< std::string > &identification_labels_to_recognize, int subs_meth, int feature_dim, bool use_unknown_thresh, bool use_depth)
virtual unsigned long initTraining (std::string data_directory, int norm_size, bool norm_illumination, bool norm_align, bool norm_extreme_illumination, bool debug, std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps, bool use_depth)
virtual unsigned long loadRecognitionModel (std::vector< std::string > &identification_labels_to_recognize)
virtual unsigned long saveRecognitionModel ()
virtual unsigned long saveTrainingData (std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps)
virtual unsigned long saveTrainingData (std::vector< cv::Mat > &face_images)
virtual unsigned long trainRecognitionModel (std::vector< std::string > &identification_labels_to_train)
virtual unsigned long updateFaceLabel (int index, std::string new_label)
virtual unsigned long updateFaceLabels (std::string old_label, std::string new_label)
 ~FaceRecognizer (void)
 Destructor.

Protected Member Functions

void assertDirectories (boost::filesystem::path &data_directory)
virtual unsigned long convertAndResize (cv::Mat &img, cv::Mat &resized, cv::Rect &face, cv::Size new_size)
virtual unsigned long loadTrainingData (std::vector< cv::Mat > &face_images, std::vector< std::string > &identification_labels_to_train)
virtual unsigned long loadTrainingData (std::vector< cv::Mat > &face_images, std::vector< cv::Mat > &face_depthmaps, std::vector< std::string > &identification_labels_to_train)
virtual unsigned long recognizeFace (cv::Mat &color_image, std::vector< cv::Rect > &face_coordinates, std::vector< std::string > &identification_labels)
virtual unsigned long recognizeFace (cv::Mat &color_image, cv::Mat &depth_image, std::vector< cv::Rect > &face_coordinates, std::vector< std::string > &identification_labels)
unsigned long trainFaceRecognition (ipa_PeopleDetector::FaceRecognizerBaseClass *eff, std::vector< cv::Mat > &data, std::vector< int > &labels)

Protected Attributes

std::vector< int > depth_num_labels
 Number of classes for depth training data.
std::vector< std::string > depth_str_labels
 Vector for class label strings for depth training data.
std::vector< std::string > depth_str_labels_unique
 Vector for class unique label strings for depth training data.
std::vector< bool > dm_exist
 vector indicating if depth map exists for corresponding color image
ipa_PeopleDetector::FaceRecognizerBaseClasseff_color
 FaceRecognizer for color images.
ipa_PeopleDetector::FaceRecognizerBaseClasseff_depth
 FaceRecognizer for depth maps.
FaceNormalizer face_normalizer_
 Face normalizer object.
cv::Mat m_average_image
 Trained average Image.
std::vector< std::string > m_current_label_set
 A vector containing all different labels from the training session exactly once, order of appearance matters! (m_current_label_set[i] stores the corresponding name to the average face coordinates in the face subspace in m_face_class_average_projections.rows(i))
boost::filesystem::path m_data_directory
 folder that contains the training data
boost::mutex m_data_mutex
 secures the internal data variables against usage during training
bool m_debug
 enables some debug outputs
bool m_depth_mode
 flag indicates if depth maps are ignored or used for classification
cv::Mat m_eigenvalues
 Eigenvalues.
std::vector< cv::Mat > m_eigenvectors
 Eigenvectors (spanning the face space)
IplImage ** m_eigenvectors_ipl
 Eigenvalues stored in IplImage format (to avoid conversion each time the function is called)
int m_eigenvectors_per_person
 Number of eigenvectors per person to identify -> controls the total number of eigenvectors.
cv::Mat m_face_class_average_projections
 The average factors of the eigenvector decomposition from each face class; The average factors from each face class originating from the eigenvector decomposition.
cv::SVM m_face_classifier
 classifier for the identity of a person
std::vector< std::string > m_face_labels
 A vector containing the corresponding labels to each face image projection in m_projected_training_faces (m_face_labels[i] stores the corresponding name to the face representation in the face subspace in m_projected_training_faces.rows(i))
int m_feature_dim
 Dimension of features that is computed when using Eigenfaces,2D-PCA, 2D-LDA.
std::vector< int > m_label_num
int m_metric
 metric for nearest neighbor search in face space: 0 = Euklidean, 1 = Mahalanobis, 2 = Mahalanobis Cosine
int m_norm_size
 Desired width and height of the Eigenfaces (=eigenvectors).
cv::Mat m_projected_training_faces
 Projected training faces (coefficients for the eigenvectors of the face subspace)
int m_rec_method
 flag for recognition method
ipa_PeopleDetector::Method m_subs_meth
 recognition method
double m_threshold_facespace
 Threshold to facespace.
double m_threshold_unknown
 Threshold to detect unknown faces.
bool m_use_unknown_thresh
 flag indicates if unknown threshold is used

Detailed Description

Definition at line 87 of file face_recognizer.h.


Member Enumeration Documentation

Enumerator:
EUCLIDEAN 
MAHALANOBIS 
MAHALANOBISCOSINE 

Definition at line 165 of file face_recognizer.h.


Constructor & Destructor Documentation

Constructor.

Constructor

Definition at line 86 of file face_recognizer.cpp.

Destructor.

Definition at line 92 of file face_recognizer.cpp.


Member Function Documentation

unsigned long ipa_PeopleDetector::FaceRecognizer::addFace ( cv::Mat &  color_image,
cv::Mat &  depth_image,
cv::Rect &  face_bounding_box,
cv::Rect &  head_bounding_box,
std::string  label,
std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps 
) [virtual]

Function to add a new face The function adds a new face to the trained images. The labels are stored internally in m_face_labels. The face_images are stored externally to avoid waste of memory.

Parameters:
color_imageColor image containing the face
face_bounding_boxRectangular bounding box of the detected face
labelLabel of the new face
face_imagesVector containing all trained images
Returns:
Return code

Definition at line 202 of file face_recognizer.cpp.

void ipa_PeopleDetector::FaceRecognizer::assertDirectories ( boost::filesystem::path &  data_directory) [protected]

Function can be used to verify the existence of the data directory and created if it does not exist. Assertion of the data directory

Parameters:
[in]data_directoryPath to top level directory with training data

Definition at line 919 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::convertAndResize ( cv::Mat &  img,
cv::Mat &  resized,
cv::Rect &  face,
cv::Size  new_size 
) [protected, virtual]

Function to find the closest face class The function calculates the distance of each sample image to the trained face class

Parameters:
eigen_vector_weightsThe weights of corresponding eigenvectors of projected test face
face_labelLabel of closest face, or 'Unknown' if the face is unknown
number_eigenvectorsNumber of eigenvalues
Returns:
Return code

Definition at line 588 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::deleteFace ( int  index,
std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps 
) [virtual]

Deletes the database entry with the provided index.

Parameters:
indexThe index of the database entry which shall be deleted
face_imagesVector containing all trained images
Returns:
Return code

Definition at line 260 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::deleteFaces ( std::string  label,
std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps 
) [virtual]

Deletes all database entries with the provided label.

Parameters:
labelThe label of the database entries which shall be deleted
face_imagesVector containing all trained images
Returns:
Return code

Definition at line 246 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::init ( std::string  data_directory,
int  norm_size,
bool  norm_illumination,
bool  norm_align,
bool  norm_extreme_illumination,
int  metric,
bool  debug,
std::vector< std::string > &  identification_labels_to_recognize,
int  subs_meth,
int  feature_dim,
bool  use_unknown_thresh,
bool  use_depth 
) [virtual]

Initialization function. Parameters: see class member explanations.

Parameters:
data_directoryThe directory for data files
identification_labels_to_recognizeA list of labels of persons that shall be recognized
Returns:
Return code

Definition at line 102 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::initTraining ( std::string  data_directory,
int  norm_size,
bool  norm_illumination,
bool  norm_align,
bool  norm_extreme_illumination,
bool  debug,
std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps,
bool  use_depth 
) [virtual]

Initialization function for training purposes (only for capturing images, not the training of recognition models). Parameters: see class member explanations.

Parameters:
data_directoryThe directory for data files
face_imagesA list of images of persons that shall be recognized which will be loaded by the function.
Returns:
Return code

Definition at line 173 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::loadRecognitionModel ( std::vector< std::string > &  identification_labels_to_recognize) [virtual]

Loads a model for the recognition of a given set of faces.

Parameters:
identification_labels_to_recognizeList of labels whose corresponding faces shall be available for recognition
Returns:
Return code

Implements ipa_PeopleDetector::AbstractFaceRecognizer.

Definition at line 368 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::loadTrainingData ( std::vector< cv::Mat > &  face_images,
std::vector< std::string > &  identification_labels_to_train 
) [protected, virtual]

Loads the training data for the persons specified in identification_labels_to_train

Parameters:
face_imagesA vector containing all training images
identification_indices_to_trainList of labels whose corresponding faces shall be trained. If empty, all available data is used and this list is filled with the labels.
Returns:
Return code

Definition at line 713 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::loadTrainingData ( std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps,
std::vector< std::string > &  identification_labels_to_train 
) [protected, virtual]

Definition at line 807 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::recognizeFace ( cv::Mat &  color_image,
std::vector< cv::Rect > &  face_coordinates,
std::vector< std::string > &  identification_labels 
) [protected, virtual]

Function to Recognize faces The function recognize the faces

Parameters:
color_imagesource color image
face_coordinatesBounding boxes of detected faces (input parameter)
identification_labelsVector of labels of classified faces, vector indices correspond with bounding boxes in face_coordinates
Returns:
Return code

Implements ipa_PeopleDetector::AbstractFaceRecognizer.

Definition at line 474 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::recognizeFace ( cv::Mat &  color_image,
cv::Mat &  depth_image,
std::vector< cv::Rect > &  face_coordinates,
std::vector< std::string > &  identification_labels 
) [protected, virtual]

Implements ipa_PeopleDetector::AbstractFaceRecognizer.

Definition at line 528 of file face_recognizer.cpp.

Saves the currently trained model for the recognition of a given set of faces.

Returns:
Return code

Implements ipa_PeopleDetector::AbstractFaceRecognizer.

Definition at line 323 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::saveTrainingData ( std::vector< cv::Mat > &  face_images,
std::vector< cv::Mat > &  face_depthmaps 
) [virtual]

Saves the training data

Parameters:
face_imagesA vector containing all training images
Returns:
Return code

Definition at line 645 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::saveTrainingData ( std::vector< cv::Mat > &  face_images) [virtual]

Definition at line 598 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::trainFaceRecognition ( ipa_PeopleDetector::FaceRecognizerBaseClass eff,
std::vector< cv::Mat > &  data,
std::vector< int > &  labels 
) [protected]

Definition at line 267 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::trainRecognitionModel ( std::vector< std::string > &  identification_labels_to_train) [virtual]

Trains a model for the recognition of a given set of faces.

Parameters:
identification_indices_to_trainList of labels whose corresponding faces shall be trained. If empty, all available data is used and this list is filled with the labels.
Returns:
Return code

Implements ipa_PeopleDetector::AbstractFaceRecognizer.

Definition at line 287 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::updateFaceLabel ( int  index,
std::string  new_label 
) [virtual]

Updates the label of a single face in the database.

Parameters:
indexThe index of the face in the database whose label shall be replaced by the new label
new_labelThe new label
Returns:
Return code

Definition at line 240 of file face_recognizer.cpp.

unsigned long ipa_PeopleDetector::FaceRecognizer::updateFaceLabels ( std::string  old_label,
std::string  new_label 
) [virtual]

Updates the labels of a stored person.

Parameters:
old_labelThe label in the database which shall be replaced by the new label
new_labelThe new label
Returns:
Return code

Definition at line 230 of file face_recognizer.cpp.


Member Data Documentation

Number of classes for depth training data.

Definition at line 204 of file face_recognizer.h.

std::vector<std::string> ipa_PeopleDetector::FaceRecognizer::depth_str_labels [protected]

Vector for class label strings for depth training data.

Definition at line 202 of file face_recognizer.h.

Vector for class unique label strings for depth training data.

Definition at line 203 of file face_recognizer.h.

std::vector<bool> ipa_PeopleDetector::FaceRecognizer::dm_exist [protected]

vector indicating if depth map exists for corresponding color image

Definition at line 212 of file face_recognizer.h.

FaceRecognizer for color images.

Definition at line 209 of file face_recognizer.h.

FaceRecognizer for depth maps.

Definition at line 208 of file face_recognizer.h.

Face normalizer object.

Definition at line 206 of file face_recognizer.h.

Trained average Image.

Definition at line 224 of file face_recognizer.h.

std::vector<std::string> ipa_PeopleDetector::FaceRecognizer::m_current_label_set [protected]

A vector containing all different labels from the training session exactly once, order of appearance matters! (m_current_label_set[i] stores the corresponding name to the average face coordinates in the face subspace in m_face_class_average_projections.rows(i))

Definition at line 228 of file face_recognizer.h.

boost::filesystem::path ipa_PeopleDetector::FaceRecognizer::m_data_directory [protected]

folder that contains the training data

Definition at line 230 of file face_recognizer.h.

secures the internal data variables against usage during training

Definition at line 233 of file face_recognizer.h.

enables some debug outputs

Definition at line 241 of file face_recognizer.h.

flag indicates if depth maps are ignored or used for classification

Definition at line 213 of file face_recognizer.h.

Eigenvalues.

Definition at line 223 of file face_recognizer.h.

std::vector<cv::Mat> ipa_PeopleDetector::FaceRecognizer::m_eigenvectors [protected]

Eigenvectors (spanning the face space)

Definition at line 221 of file face_recognizer.h.

Eigenvalues stored in IplImage format (to avoid conversion each time the function is called)

Definition at line 222 of file face_recognizer.h.

Number of eigenvectors per person to identify -> controls the total number of eigenvectors.

Definition at line 237 of file face_recognizer.h.

The average factors of the eigenvector decomposition from each face class; The average factors from each face class originating from the eigenvector decomposition.

Definition at line 227 of file face_recognizer.h.

classifier for the identity of a person

Definition at line 229 of file face_recognizer.h.

std::vector<std::string> ipa_PeopleDetector::FaceRecognizer::m_face_labels [protected]

A vector containing the corresponding labels to each face image projection in m_projected_training_faces (m_face_labels[i] stores the corresponding name to the face representation in the face subspace in m_projected_training_faces.rows(i))

Definition at line 226 of file face_recognizer.h.

Dimension of features that is computed when using Eigenfaces,2D-PCA, 2D-LDA.

Definition at line 243 of file face_recognizer.h.

Definition at line 210 of file face_recognizer.h.

metric for nearest neighbor search in face space: 0 = Euklidean, 1 = Mahalanobis, 2 = Mahalanobis Cosine

Definition at line 240 of file face_recognizer.h.

Desired width and height of the Eigenfaces (=eigenvectors).

Definition at line 236 of file face_recognizer.h.

Projected training faces (coefficients for the eigenvectors of the face subspace)

Definition at line 225 of file face_recognizer.h.

flag for recognition method

Definition at line 211 of file face_recognizer.h.

recognition method

Definition at line 214 of file face_recognizer.h.

Threshold to facespace.

Definition at line 238 of file face_recognizer.h.

Threshold to detect unknown faces.

Definition at line 239 of file face_recognizer.h.

flag indicates if unknown threshold is used

Definition at line 215 of file face_recognizer.h.


The documentation for this class was generated from the following files:


cob_people_detection
Author(s): Richard Bormann , Thomas Zwölfer
autogenerated on Fri Aug 28 2015 10:24:13