asmlib-opencv
an ASM(Active Shape Model) implementation by C++ & OpenCV
|
The Statistical Shape model for training sets. More...
#include <shapemodel.h>
Classes | |
struct | ModelViewInfo |
Used for viewing model. More... | |
Public Member Functions | |
ShapeModel () | |
virtual void | saveToFile (ModelFile &file) |
Save the model into a file. | |
virtual void | loadFromFile (ModelFile &file) |
Load the model from a file. | |
void | readTrainData (const char *listFileName) |
File names are stored in the list file. | |
void | loadShapeInfo (const char *shapeFileName) |
Load shape information. | |
void | setPyramidLevel (int l) |
Set the level for the image pyramid. | |
void | projectParamToShape (const Mat_< double > ¶mVec, ShapeVec &shapeVec) |
Project a parameter vector to a shape. | |
void | projectShapeToParam (const ShapeVec &shapeVec, Mat_< double > ¶mVec) |
Project a shape to a parameter vector. | |
ShapeInfo & | getShapeInfo () |
Mat_< double > | normalizeParam (const Mat_< double > &p) |
Normalize an parameter vector(0..1) | |
Mat_< double > | reConFromNorm (const Mat_< double > &p) |
Reconstruct parameter vector from normalized vector. | |
void | viewShapeModel () |
An interactive UI for viewing the statistical model. | |
void | viewShapeModelUpdate (ModelViewInfo *pInfo) |
Update viewing UI with new parameters. (called by callbacks) | |
Protected Member Functions | |
void | clampParamVec (Mat_< double > ¶mVec) |
Refine a parameter vector by clamping. | |
void | buildModel (const string &shapeDefFile, const string &ptsListFile) |
Align the shapes and build a model. | |
Protected Attributes | |
int | pyramidLevel |
level for the image pyramid. | |
int | nMarkPoints |
Number of landmark points in a image. | |
int | nTrain |
Number of training images. | |
vector< ModelImage > | imageSet |
All the images, with labelled markpoints. | |
ShapeInfo | shapeInfo |
Path info for shapes;. | |
ShapeVec | meanShape |
Mean shape after aligning. | |
PCA * | pcaShape |
PCA model for shapes. | |
int | nShapeParams |
Number of eigen vectors reserved for shape model. | |
double | sigma2 |
Data for BTSM: . | |
PCA * | pcaFullShape |
Data for BTSM: Full . | |
double | searchYOffset |
r.y -= r.height*? | |
double | searchXOffset |
r.x -= r.width*? | |
double | searchWScale |
r.width *= ? | |
double | searchHScale |
r.height *= ? | |
double | searchStepAreaRatio |
step: ?*100/sqrt(area) | |
double | searchScaleRatio |
init scale ratio when searching | |
double | searchInitXOffset |
init X offset when searching | |
double | searchInitYOffset |
init Y offset when searching |
The Statistical Shape model for training sets.
After all the training shapes are aligned, a PCA model is built so that a shape can be roughly described by a few parameters (PCA coefficients).
This class is responsible for building the statistical shape model and provides some helper functions.
void StatModel::ShapeModel::buildModel | ( | const string & | shapeDefFile, |
const string & | ptsListFile | ||
) | [protected] |
Align the shapes and build a model.
shapeDefFile | Shape definition file. |
ptsListFile | File containting a list of pts files. |
Reimplemented in StatModel::ASMModel.
void StatModel::ShapeModel::clampParamVec | ( | Mat_< double > & | paramVec | ) | [protected] |
Refine a parameter vector by clamping.
: Change "3" to a configurable variable.
ShapeInfo& StatModel::ShapeModel::getShapeInfo | ( | ) | [inline] |
void StatModel::ShapeModel::loadFromFile | ( | ModelFile & | file | ) | [virtual] |
Load the model from a file.
void StatModel::ShapeModel::loadShapeInfo | ( | const char * | shapeFileName | ) |
Load shape information.
Mat_< double > StatModel::ShapeModel::normalizeParam | ( | const Mat_< double > & | p | ) | [inline] |
Normalize an parameter vector(0..1)
void StatModel::ShapeModel::projectParamToShape | ( | const Mat_< double > & | paramVec, |
ShapeVec & | shapeVec | ||
) |
Project a parameter vector to a shape.
paramVec | parameter vector. |
shapeVec | the shape corresponding to the parameter vector |
void StatModel::ShapeModel::projectShapeToParam | ( | const ShapeVec & | shapeVec, |
Mat_< double > & | paramVec | ||
) |
Project a shape to a parameter vector.
shapeVec | the shape corresponding to the parameter vector |
paramVec | parameter vector. |
void StatModel::ShapeModel::readTrainData | ( | const char * | listFileName | ) |
File names are stored in the list file.
Mat_< double > StatModel::ShapeModel::reConFromNorm | ( | const Mat_< double > & | p | ) | [inline] |
Reconstruct parameter vector from normalized vector.
void StatModel::ShapeModel::saveToFile | ( | ModelFile & | file | ) | [virtual] |
Save the model into a file.
void StatModel::ShapeModel::setPyramidLevel | ( | int | l | ) | [inline] |
Set the level for the image pyramid.
l | Image from level 0 to l will be considered during training and searching. |
An interactive UI for viewing the statistical model.
void StatModel::ShapeModel::viewShapeModelUpdate | ( | ModelViewInfo * | pInfo | ) |
Update viewing UI with new parameters. (called by callbacks)
vector<ModelImage> StatModel::ShapeModel::imageSet [protected] |
All the images, with labelled markpoints.
ShapeVec StatModel::ShapeModel::meanShape [protected] |
Mean shape after aligning.
int StatModel::ShapeModel::nMarkPoints [protected] |
Number of landmark points in a image.
int StatModel::ShapeModel::nShapeParams [protected] |
Number of eigen vectors reserved for shape model.
int StatModel::ShapeModel::nTrain [protected] |
Number of training images.
PCA* StatModel::ShapeModel::pcaFullShape [protected] |
Data for BTSM: Full .
PCA* StatModel::ShapeModel::pcaShape [protected] |
PCA model for shapes.
int StatModel::ShapeModel::pyramidLevel [protected] |
level for the image pyramid.
double StatModel::ShapeModel::searchHScale [protected] |
r.height *= ?
double StatModel::ShapeModel::searchInitXOffset [protected] |
init X offset when searching
double StatModel::ShapeModel::searchInitYOffset [protected] |
init Y offset when searching
double StatModel::ShapeModel::searchScaleRatio [protected] |
init scale ratio when searching
double StatModel::ShapeModel::searchStepAreaRatio [protected] |
step: ?*100/sqrt(area)
double StatModel::ShapeModel::searchWScale [protected] |
r.width *= ?
double StatModel::ShapeModel::searchXOffset [protected] |
r.x -= r.width*?
double StatModel::ShapeModel::searchYOffset [protected] |
r.y -= r.height*?
ShapeInfo StatModel::ShapeModel::shapeInfo [protected] |
Path info for shapes;.
double StatModel::ShapeModel::sigma2 [protected] |
Data for BTSM: .