Back AAM-API documentation The AAM-Site

In file AAMBuilder.h:

class CAAMBuilder

Factory object that produces CAAMModel objects.

Inheritance:

CAAMBuilder - CAAMObject


Public Methods

[more]void BuildFromFiles( CAAMModel &model, const std::vector<CString> &asfFiles, const CString &acf, const int modelReduction, const int excludeShape )
Diver method for model generation.
[more]void BuildFromFiles( CAAMModel &model, const CString &inDir, const CString &acf, const int modelReduction, const int excludeShape )
Diver method for model generation.
[more]void BuildTextureVectors()
Samples all shapes in the training set and build the corresponding texture vectores.
[more] CAAMBuilder()
Constructor.
[more]std::vector<CDVector> CParamDispVectors( const CDVector &vStdDisp, const std::vector<CDVector> &cVectors, const int pStart, const int pLen ) const
Generates a set combined model parameter displacement vectors.
[more]void CalcPixel2ShapeWeights()
Calculates the pixel-to-shape weights.
[more]void DisplacementSets( std::vector<CDVector> &vCDisps, std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors ) const
Generates model parameter and pose displacement sets.
[more]void DoCParamExperiments( const std::vector<CDVector> &vCDisps, const std::vector<CDVector> &cVectors, CDMatrix &X, CDMatrix &C, const int ts_subsampling ) const
Performs a set of model parameter displacement experiments.
[more]std::vector<CDVector> DoCombinedPCA()
Performs PCA on shape and texture data.
[more]void DoPoseExperiments( const std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors, CDMatrix &X, CDMatrix &C, const int ts_subsampling ) const
Performs a set of pose parameter displacement experiments.
[more]void DoShapeAlignment( const bool fUseTangentSpace )
Aligns shapes and calc mean- and reference-shape.
[more]void DumpModelDoc( std::vector<CDVector> bVectors )
Write additional documentation output.
[more]void DumpPCA( const std::vector<CDVector> &bVectors )
Dumps the PC scores of the shape, texture and combined PCA.
[more]void EstCParamGradientMatrix( const std::vector<CDVector> &vCDisps, const std::vector<CDVector> &cVectors, CDMatrix &Gparam, const int ts_subsampling) const
Estimates the Jacobian of the model parameters.
[more]void EstPoseGradientMatrix( const std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors, CDMatrix &Gpose, const int ts_subsampling ) const
Estimates the Jacobian of the pose parameters.
[more]void EstPredictionMatrices( const std::vector<CDVector> &bVectors, const int ts_subsampling )
Build the prediction matrices for pose and parameter prediction.
[more]void EstRegressionMatrices( const std::vector<CDVector> &bVectors, const int ts_subsampling )
Build the regression matrices for pose and parameter prediction.
[more]bool LoadShapes( const std::vector<CString> &asfFiles, CAAMShapeCollection &destination, int modelReduction, bool addCompleteImage, double addExtents, int excludeShape )
Loads (and preprocess) all training shapes.
[more]void MapTextures()
Performs a mapping of all textures in 'm_vTexture'.
[more]void ModelDisplacement( const CDMultiBand<TAAMPixel> &image, const CAAMShape &shape, const CDVector &c0, const CDVector &delta_c, CDVector &pixel_diff ) const
Performs one model parameter regression experiment.
[more]void NormalizeTextureVectors()
Iterative normalization of the texture samples.
[more]std::vector<CDVector> PoseDispVectors( const CDVector &vXDisp, const CDVector &vYDisp, const CDVector &vScaleDisp, const CDVector &vRotDisp ) const
Generates a set pose displacement vectors.
[more]void PoseDisplacement( const CDMultiBand<TAAMPixel> &image, const CAAMShape &shape, const CDVector &c0, const CDVector &t, CDVector &pixel_diff ) const
Performs one pose regression experiment.
[more]bool ReadACF( const CString &filename )
Reads and parses an ACF file.
[more]void RecalcMeanTexture( )
Recalculates the mean texture vector 'm_vMeanTexture'.
[more] ~CAAMBuilder()
Destructor.

Protected Fields

[more]CAAMShapeCollection m_AlignedShapes
The aligned shapes
[more]CAAMShapeCollection m_Shapes
The raw (unaligned) shapes
[more]CAAMModel* m_pModel
Pointer to the model we're building
[more]std::vector<CDVector> m_vTexture
The texture samples


Inherited from CAAMObject:

Public Methods

ovoid Dump( const char* szPath ) const
ovoid FromFile( const char* szFilename )
ovoid FromFile( FILE* fh )
ovoid ToFile( FILE* fh ) const
ovoid ToFile( const char* szFilename ) const


Documentation

Factory object that produces CAAMModel objects. Main tasks are the estimation of parameter update matrices and verbose dumping of model information. Most other tasks are simple calls into CAAMModel, CAAMShape etc.

oCAAMShapeCollection m_Shapes
The raw (unaligned) shapes

oCAAMShapeCollection m_AlignedShapes
The aligned shapes

ostd::vector<CDVector> m_vTexture
The texture samples

oCAAMModel* m_pModel
Pointer to the model we're building

ovoid BuildFromFiles( CAAMModel &model, const CString &inDir, const CString &acf, const int modelReduction, const int excludeShape )

This method automates the model generation as much as possible by using the various class methods for all the sequences in the task of producing a model.

Parameters:
model - The generated model.
inDir - Input directory where annotations (.asf) resides.
acf - Filename of an AAM configuration file. If omitted defaults are used.
modelReduction - Model reduction multiplier. Default off == 1. Useful when building multi-scale AAMs.
excludeShape - Excludes one shape number 'excludeShape' from the input directory. Default -1, i.e. no shapes are removed. Used to perform leave-one-out testing.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
4-14-2000

ovoid BuildFromFiles( CAAMModel &model, const std::vector<CString> &asfFiles, const CString &acf, const int modelReduction, const int excludeShape )

This method automates the model generation as much as possible by using the various class methods for all the sequences in the task of producing a model.

Parameters:
model - The generated model.
asfFiles - Vector of asf filenames.
acf - Filename of an AAM configuration file. If omitted defaults are used.
modelReduction - Model reduction multiplier. Default off == 1. Useful when building multi-scale AAMs.
excludeShape - Excludes one shape number 'excludeShape' from the input directory. Default -1, i.e. no shapes are removed. Used to perform leave-one-out testing.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
4-14-2000

obool LoadShapes( const std::vector<CString> &asfFiles, CAAMShapeCollection &destination, int modelReduction, bool addCompleteImage, double addExtents, int excludeShape )

Loads (and preprocess) all training shapes into a CAAMShapeCollection. This could as well be placed in CAAMUtil actually.

Parameters:
asfFiles - An array of asf filenames.
destination - Output shape collection.
modelReduction - Optional size reduction. Default 1, i.e. no reduction.
addCompleteImage - Set this to true if you (for wird reasons) would like add the corners of the image to the shape. Default false.
addExtents - Simple and somewhat hacked way to add a shape neighborhood (will be removed in later versions).
excludeShape - If != -1 the the 'excludeShape'-th shape will be excluded. Zero is the first shape. Used for leave-one-out evaluation.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
11-4-2002

ovoid MapTextures()

Performs a mapping of all textures in 'm_vTexture' using the texture transfer class of the model.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
1-28-2002

ovoid DumpModelDoc( std::vector<CDVector> bVectors )

Write additional documentation output.

Parameters:
bVectors - Concatenated and weighted shape and texture vectors over the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
1-28-2002

ovoid EstRegressionMatrices( const std::vector<CDVector> &bVectors, const int ts_subsampling )

Build the regression matrices for pose and parameter prediction. I.e. calculates the member variables 'regR_c', 'regR_t'. using principal component regression.

Parameters:
bVectors - The b-vectors for the training set the current AAM is built upon. [Can be optained from the DoCombinedPCA() call]
ts_subsampling - Controls the sub sampling of the training set - i.e. to use every fifth shape to build the regression matrices upon, set shape_subsampling = 5; The motivation for doing this is reduction of model building time -- and perhaps most importantly -- conservation of memory resources.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-14-2000

ovoid DoPoseExperiments( const std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors, CDMatrix &X, CDMatrix &C, const int ts_subsampling ) const

Performs a set of pose parameter displacement experiments on the training set given a set of displacment vectors.

Parameters:
vPoseDisps - A vector of displacement vectors as obtained from PoseDispVectors() or DisplacementSets().
cVectors - The set of optimum c vectors for the training examples.
X - Output matrix containing the texture difference vectors obtained from the displacements.
Y - Output matrix containing the model parameter displacements carried out.
ts_subsampling - Subsampling factor, i.e. ts_subsampling==n will carry out displacements on every n-th example in the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
5-13-2002
See Also:
DoPoseExperiments

ovoid DoCParamExperiments( const std::vector<CDVector> &vCDisps, const std::vector<CDVector> &cVectors, CDMatrix &X, CDMatrix &C, const int ts_subsampling ) const

Performs a set of model parameter displacement experiments on the training set given a set of displacment vectors.

Parameters:
vCDisps - A vector of displacement vectors as obtained from CParamDispVectors() or DisplacementSets().
cVectors - The set of optimum c vectors for the training examples.
X - Output matrix containing the texture difference vectors obtained from the displacements.
Y - Output matrix containing the model parameter displacements carried out.
ts_subsampling - Subsampling factor, i.e. ts_subsampling==n will carry out displacements on every n-th example in the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
5-13-2002
See Also:
DoPoseExperiments

ovoid DisplacementSets( std::vector<CDVector> &vCDisps, std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors ) const

Generates model parameter and pose displacement sets.

Parameters:
vCDisps - Resulting model parameter displacement set.
vPoseDisps - Resulting pose parameter displacement set.
cVectors - The set of c vectors over the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-14-2000
See Also:
CParamDispVectors, PoseDispVectors

ostd::vector<CDVector> CParamDispVectors( const CDVector &vStdDisp, const std::vector<CDVector> &cVectors, const int pStart, const int pLen ) const

Generates a set combined model parameter displacement vectors where each parameter is displaced at a time according to the values in vStdDisp.

Parameters:
vStdDisp - A vector of parameter displacements in standard deviations of the corresponding parameter.
cVectors - The set of c vectors over the training set.
pStart - The first parameter to displace. (default 0).
pLen - The number of parameters to displace. (default 0, which means all parameters).
Returns:
A vector of displacement vectors.
Author:
Mikkel B. Stegmann
Version:
3-14-2000
See Also:
CParamDispVectors

ostd::vector<CDVector> PoseDispVectors( const CDVector &vXDisp, const CDVector &vYDisp, const CDVector &vScaleDisp, const CDVector &vRotDisp ) const

Generates a set pose displacement vectors.

Parameters:
vXDisp - A vector of x displacements in pixels.
vYDisp - A vector of y displacements in pixels.
vScaleDisp - A vector of scale displacements (1.0=no scaling).
vRotDisp - A vector of rotation displacements in degrees.
Returns:
A vector of displacement vectors.
Author:
Mikkel B. Stegmann
Version:
3-14-2000
See Also:
CParamDispVectors

ovoid BuildTextureVectors()

Initializes the private member: 'm_vTexture' by sampling all shapes using a warp function. Note that this method calculates the mean texture.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
2-21-2000

o CAAMBuilder()

Constructor. Sets up default values for the settings usally given by an acf file.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
10-26-2000

o ~CAAMBuilder()

Destructor.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
10-26-2000

ovoid CalcPixel2ShapeWeights()

Calculates the pixel-to-shape weights used in the combined PCA. Currently the simple 'split even' strategy is employed, i.e. normalise shape and texture variance to be equal.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-6-2000

ovoid PoseDisplacement( const CDMultiBand<TAAMPixel> &image, const CAAMShape &shape, const CDVector &c0, const CDVector &t, CDVector &pixel_diff ) const

Performs one pose regression experiment.

Parameters:
image - The image corresponding to the equibrilium shape.
shape - The equibrilium shape.
c0 - The equibrilium model parameters.
t - The pose displacement parameters.
pixel_diff - The normalized pixel differences resulting from the pose displacement.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-14-2000
See Also:
ModelDisplacement

ovoid ModelDisplacement( const CDMultiBand<TAAMPixel> &image, const CAAMShape &shape, const CDVector &c0, const CDVector &delta_c, CDVector &pixel_diff ) const

Performs one model parameter regression experiment.

Parameters:
image - The image corresponding to the equibrilium shape.
shape - The equibrilium shape.
c0 - The equibrilium model parameters.
delta_c - The model parameter displacements.
pixel_diff - The normalized pixel differences resulting from the pose displacement.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
3-14-2000
See Also:
PoseDisplacement

ovoid DoShapeAlignment( const bool fUseTangentSpace )

Alignes shapes and calc mean- and reference-shape. I.e. initializes 'm_AlignedShapes', 'm_sMeanAShape' and 'm_sReferenceShape'.

Parameters:
fUseTangentSpace - Use the tangent space projection (bool).
Returns:
Noting.
Author:
Mikkel B. Stegmann
Version:
10-24-2000

ovoid DumpPCA( const std::vector<CDVector> &bVectors )

Dumps the PC scores of the shape, texture and combined PCA. These are written to the current directory in Matlab format as shape_pc.m, texture_pc.m and combined_pc, respectively.

param bVectors The b-parameters for all training examples. As obtained from DoCombinedPCA().

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
5-17-2000

ovoid NormalizeTextureVectors()

Performs normalization of the texture vectors as described by Cootes et al. in "Active Appearance Models" sec. 2. Recalculates the mean texture.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
2-22-2000

obool ReadACF( const CString &filename )

Reads and parses an ACF file. In this way the AAM can be configured using different setting for model generation. Note that all parsing is very primitive and in no way robust :-( So be careful about the configuration files.

Parameters:
filename - The acf file to open.
Returns:
true on success, false on file errors.
Author:
Mikkel B. Stegmann
Version:
4-17-2000

ovoid RecalcMeanTexture( )

Recalculates the mean texture vector 'm_vMeanTexture'.

Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
2-22-2000

ostd::vector<CDVector> DoCombinedPCA()

Performs principal component analysis on the shape and the texture data. Uses the Eckhart-Young theorem described in appendix A of "Statistical Models of Appearance of Computer Vision" by T.F. Cootes et al. if we have fewer samples than dimensions which is typically the case.

Returns:
The b-parameters for all training examples. The format is a vector of b-parameter vectors. This vector is used in the BuildRegressionMatrices() call.
Author:
Mikkel B. Stegmann
Version:
2-23-2000

ovoid EstPredictionMatrices( const std::vector<CDVector> &bVectors, const int ts_subsampling )

Build the prediction matrices for pose and parameter prediction. I.e. calculates the member variables 'regR_c', 'regR_t'. using estimates of the gradient matrices.

Parameters:
bVectors - The b-vectors for the training set the current AAM is built upon. [Can be optained from the DoCombinedPCA() call]
ts_subsampling - Controls the sub sampling of the training set - i.e. to use every fifth shape to build the regression matrices upon, set shape_subsampling = 5; The motivation for doing this is reduction of model building time.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
7-18-2002

ovoid EstPoseGradientMatrix( const std::vector<CDVector> &vPoseDisps, const std::vector<CDVector> &cVectors, CDMatrix &Gpose, const int ts_subsampling ) const

Estimates the Jacobian of the pose parameters given a set of displacement vectors and the optimum model parameters for the training set.

Parameters:
vPoseDisps - A vector of displacement vectors as obtained from PoseDispVectors() or DisplacementSets().
cVectors - The set of optimum c vectors for the training examples.
Gpose - The output Jacobian matrix (or gradient matrix if you like).
ts_subsampling - Subsampling factor, i.e. ts_subsampling==n will carry out displacements on every n-th example in the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
7-18-2002
See Also:
EstCParamGradientMatrix

ovoid EstCParamGradientMatrix( const std::vector<CDVector> &vCDisps, const std::vector<CDVector> &cVectors, CDMatrix &Gparam, const int ts_subsampling) const

Estimates the Jacobian of the model parameters given a set of displacement vectors and the optimum model parameters for the training set.

Parameters:
vCDisps - A vector of displacement vectors as obtained from CParamDispVectors() or DisplacementSets().
cVectors - The set of optimum c vectors for the training examples.
Gparam - The output Jacobian matrix (or gradient matrix if you like).
ts_subsampling - Subsampling factor, i.e. ts_subsampling==n will carry out displacements on every n-th example in the training set.
Returns:
Nothing.
Author:
Mikkel B. Stegmann
Version:
7-18-2002
See Also:
EstPoseGradientMatrix


This class has no child classes.
Author:
Mikkel B. Stegmann
Version:
10-26-2000
See Also:
CAAMModel

Alphabetic index Hierarchy of classes


Back AAM-API documentation The AAM-Site