libface 0.2
Classes | Public Member Functions

libface::LibFace Class Reference

List of all members.

Classes

class  LibFacePriv

Public Member Functions

 LibFace (Mode type=ALL, const std::string &configDir=".", const std::string &cascadeDir=std::string(OPENCVDIR)+"/haarcascades")
 ~LibFace ()
int count () const
std::vector< Face > * detectFaces (const IplImage *img, const CvSize &originalSize)
std::vector< Face > * detectFaces (const std::string &filename, int scaleFactor=1)
std::vector< Face > * detectFaces (const char *image, int width, int height, int step, int depth=IPL_DEPTH_8U, int channels=1, int scaleFactor=1)
std::map< std::string,
std::string > 
getConfig ()
double getDetectionAccuracy () const
int getRecommendedImageSizeForDetection (const CvSize &size=cvSize(0, 0)) const
CvSize getRecommendedImageSizeForRecognition (const CvSize &size=cvSize(0, 0)) const
int loadConfig (const std::string &configDir)
int loadConfig (const std::map< std::string, std::string > &config)
std::vector< std::pair< int,
float > > 
recognise (const IplImage *img, std::vector< Face > *faces_p, int scaleFactor=1)
std::vector< std::pair< int,
float > > 
recognise (const std::string &filename, std::vector< Face > *faces_p, int scaleFactor=1)
std::vector< std::pair< int,
float > > 
recognise (const char *image, std::vector< Face > *faces_p, int width, int height, int step, int depth=IPL_DEPTH_8U, int channels=1, int scaleFactor=1)
std::vector< std::pair< int,
float > > 
recognise (std::vector< Face > *faces, int scaleFactor=1)
int saveConfig (const std::string &configDir)
void setDetectionAccuracy (double value)
int update (const std::string &filename, std::vector< Face > *faces=NULL, int scaleFactor=1)
int update (const char *image, std::vector< Face > *faces, int width, int height, int step, int depth=IPL_DEPTH_8U, int channels=1, int scaleFactor=1)
int update (std::vector< Face > *faces=NULL, int scaleFactor=1)
int update (const IplImage *img, std::vector< Face > *faces, int scaleFactor=1)

Constructor & Destructor Documentation

libface::LibFace::LibFace ( Mode  type = ALL,
const std::string &  configDir = ".",
const std::string &  cascadeDir = std::string(OPENCVDIR)+"/haarcascades" 
)

Constructor for the LibFace class. Type argument specifies what you want to do with the library. By default ALL is specified, meaning that it will do both face detection and recognition. DETECT can be specified to do only face detection. EIGEN can be specified to do only face recognition, without face detection.

Parameters:
typeType of the face recognition/detection/both to use. ALL by default.
configDirConfig directory of the libface library. If there is libface.xml library will try to load it. By default it is empty ("").
cascadeDirDirectory where haar cascade is. By default it is /usr/share/opencv/haarcascades
libface::LibFace::~LibFace ( )

Deconstructor for the library.


Member Function Documentation

int libface::LibFace::count ( ) const

Get the count of all faces trained

vector< Face > * libface::LibFace::detectFaces ( const IplImage *  img,
const CvSize &  originalSize 
)

Method for detecting faces in the picture with the pointer. It will attempt to check if this file was last to be loaded, if it has been then it will use last pointer. The IDs for all faces will be -1.

Parameters:
imgA pointer to the IplImage for face detection.
originalSizeOriginal size of the image.
Returns:
Vector of Face objects with ID set to -1 on each.
vector< Face > * libface::LibFace::detectFaces ( const char *  image,
int  width,
int  height,
int  step,
int  depth = IPL_DEPTH_8U,
int  channels = 1,
int  scaleFactor = 1 
)

Method for detecting faces in the picture with the specified encoding. The IDs for all faces will be -1.

Parameters:
imageA pointer to the char encoding.
widthImage width.
heightImage height.
stepStep.
depthImage depth (default: IPL_DEPTH_8U).
channelsNumber of channels in the image (default: 1).
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
Vector of Face objects with ID set to -1 on each.
std::vector<Face>* libface::LibFace::detectFaces ( const std::string &  filename,
int  scaleFactor = 1 
)

Method for detecting faces in the picture with the specified filename. It will attempt to check if this file was last to be loaded, if it has been then it will use last pointer. The IDs for all faces will be -1.

Parameters:
filenameFilename of the file to find faces in.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
Vector of Face objects with ID set to -1 on each.
map< string, string > libface::LibFace::getConfig ( )

Method for getting the configuration from the face recognition. There is no configuration for face detection. The config is returned as a mapping of strings to strings. Each key is a variable name of the config and value is data it holds. Both need to be returned in exact the same way in order for the loadConfig opertion to work. In the mean time the config can be stored in the database. Alternatively use saveConfig() method for libface to store config localy.

Returns:
Returns std::map of string to string. this can be stored and loaded back.
double libface::LibFace::getDetectionAccuracy ( ) const

Get the detection accuracy (see above for interpretation)

int libface::LibFace::getRecommendedImageSizeForDetection ( const CvSize &  size = cvSize(0,0)) const

Returns the image size (one dimension) recommended for face detection. Give the size of the available image, if possible. If the image is considerably larger, it will be rescaled automatically.

CvSize libface::LibFace::getRecommendedImageSizeForRecognition ( const CvSize &  size = cvSize(0,0)) const

Returns the image size recommended for face recognition. Note that the returned size may not preserve pixel aspect ratio. Give the size of the available image, if possible. If the image is larger, it will be rescaled automatically.

int libface::LibFace::loadConfig ( const std::string &  configDir)

Method for lading config file from the specified directory that contains libface.xml.

Parameters:
dirDirectory where the libface.xml is.
Returns:
Returns 0 is file loaded successfully.
int libface::LibFace::loadConfig ( const std::map< std::string, std::string > &  config)

Method for loading the config into libface. The config needs to be of the same format as returned by the getConfig().

Parameters:
config- a mapping of string to string with keys being variables and values are corresponding values.
Returns:
Returns 0 if operation completed as expected.
std::vector<std::pair<int, float> > libface::LibFace::recognise ( const std::string &  filename,
std::vector< Face > *  faces_p,
int  scaleFactor = 1 
)

Method to recognise faces in the given image. The array of faces will be updated with new id for each face.

Parameters:
filenameFilename of the image with the faces.
facesPointer to the std::vector of Face objects.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
Vector of integer ID's that best match the input vector of Faces, in same order
std::vector<std::pair<int, float> > libface::LibFace::recognise ( const char *  image,
std::vector< Face > *  faces_p,
int  width,
int  height,
int  step,
int  depth = IPL_DEPTH_8U,
int  channels = 1,
int  scaleFactor = 1 
)

Method to recognise faces in the given image. The array of faces will be updated with new id for each face.

Parameters:
filenameFilename of the image with the faces.
facesPointer to the std::vector of Face objects.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
Vector of integer ID's that best match the input vector of Faces, in same order
std::vector<std::pair<int, float> > libface::LibFace::recognise ( std::vector< Face > *  faces,
int  scaleFactor = 1 
)

Method to recognise faces in the given image. The array of faces will be updated with new id for each face.

Parameters:
facesPointer to the std::vector of Face objects.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
Vector of integer ID's that best match the input vector of Faces, in same order
int libface::LibFace::saveConfig ( const std::string &  configDir)

Method for saving current configuration of the face recognition library. Creates/overwrites the libface.xml file.

Parameters:
dirDirectory to store the config file in.
Returns:
Returns 0 if the save was successful.
void libface::LibFace::setDetectionAccuracy ( double  value)

Set the detection accuracy between 0 and 1. Trades speed vs accuracy: 0 is fast, 1 is slow but more accurate. Default is 0.8.

int libface::LibFace::update ( const char *  image,
std::vector< Face > *  faces,
int  width,
int  height,
int  step,
int  depth = IPL_DEPTH_8U,
int  channels = 1,
int  scaleFactor = 1 
)

Method to update the library with faces from the picture specified.

Parameters:
imageImage encoded as chars.
facesPointer to a std::vector of Face objects. Default to NULL, meaning the whole image is face.
widthWidth of the image.
heightHeight of the image.
stepStep.
depthDepth of the image (default: IPL_DEPTH_8U).
channelsNumber of channels (default: 1).
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
0 is return if update was successful.
int libface::LibFace::update ( const std::string &  filename,
std::vector< Face > *  faces = NULL,
int  scaleFactor = 1 
)

Method to update the library with faces from the picture specified.

Parameters:
filenameFilename of the image to load.
facesPointer to a sts::vector of Face objects. Default to NULL, meaning the whole image is face.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
0 is return if update was successful.
int libface::LibFace::update ( const IplImage *  img,
std::vector< Face > *  faces,
int  scaleFactor = 1 
)

Method to update the library with faces from the picture specified.

Parameters:
imgPointer to the image where faces are.
facesPointer to a std::vector of Face objects. Default to NULL, meaning the whole image is face.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
0 is return if update was successful.
int libface::LibFace::update ( std::vector< Face > *  faces = NULL,
int  scaleFactor = 1 
)

Method to update the library with faces from the picture specified.

Parameters:
filenameFilename of the image to load.
facesPointer to a std::vector of Face objects. Default to NULL, meaning the whole image is face.
scaleFactorAllows to specify if image should be scaled. Make things faster. Default not scaled (1). NOT USED at the moment.
Returns:
0 is return if update was successful.

The documentation for this class was generated from the following files:
 All Classes Files Functions