eos  0.7.1
Public Member Functions | Friends | List of all members
eos::morphablemodel::PcaModel Class Reference

This class represents a PCA-model that consists of: More...

#include <PcaModel.hpp>

Public Member Functions

 PcaModel (cv::Mat mean, cv::Mat pca_basis, cv::Mat eigenvalues, std::vector< std::array< int, 3 >> triangle_list)
 
int get_num_principal_components () const
 
int get_data_dimension () const
 
std::vector< std::array< int, 3 > > get_triangle_list () const
 
cv::Mat get_mean () const
 
cv::Vec4f get_mean_at_point (int vertex_index) const
 
cv::Mat draw_sample (float sigma=1.0f)
 
cv::Mat draw_sample (std::vector< float > coefficients) const
 
cv::Mat get_normalised_pca_basis () const
 
cv::Mat get_normalised_pca_basis (int vertex_id) const
 
cv::Mat get_unnormalised_pca_basis () const
 
cv::Mat get_unnormalised_pca_basis (int vertex_id) const
 
float get_eigenvalue (int index) const
 

Friends

class cereal::access
 

Detailed Description

This class represents a PCA-model that consists of:

It also contains a list of triangles to built a mesh as well as a mapping from landmark points to the corresponding vertex-id in the mesh. It is able to return instances of the model as meshes.

Constructor & Destructor Documentation

eos::morphablemodel::PcaModel::PcaModel ( cv::Mat  mean,
cv::Mat  pca_basis,
cv::Mat  eigenvalues,
std::vector< std::array< int, 3 >>  triangle_list 
)
inline

Construct a PCA model from given mean, normalised PCA basis, eigenvalues and triangle list.

See the documentation of the member variables for how the data should be arranged.

Parameters
[in]meanThe mean used to build the PCA model.
[in]pca_basisThe PCA basis (eigenvectors), normalised (multiplied by the eigenvalues).
[in]eigenvaluesThe eigenvalues used to build the PCA model.
[in]triangle_listAn index list of how to assemble the mesh.

Member Function Documentation

cv::Mat eos::morphablemodel::PcaModel::draw_sample ( float  sigma = 1.0f)
inline

Draws a random sample from the model, where the coefficients are drawn from a standard normal (or with the given standard deviation).

Parameters
[in]sigmaThe standard deviation.
Returns
A random sample from the model.
cv::Mat eos::morphablemodel::PcaModel::draw_sample ( std::vector< float >  coefficients) const
inline

Returns a sample from the model with the given PCA coefficients. The given coefficients should follow a standard normal distribution, i.e. not be "normalised" with their eigenvalues/variances.

Parameters
[in]coefficientsThe PCA coefficients used to generate the sample.
Returns
A model instance with given coefficients.
int eos::morphablemodel::PcaModel::get_data_dimension ( ) const
inline

Returns the dimension of the data, i.e. the number of shape dimensions.

As the data is arranged in a [x y z x y z ...] fashion, dividing this by three yields the number of vertices in the model.

Returns
The dimension of the data.
float eos::morphablemodel::PcaModel::get_eigenvalue ( int  index) const
inline

Returns an eigenvalue.

Parameters
[in]indexThe index of the eigenvalue to return.
Returns
The eigenvalue.
cv::Mat eos::morphablemodel::PcaModel::get_mean ( ) const
inline

Returns the mean of the model.

Returns
The mean of the model.
cv::Vec4f eos::morphablemodel::PcaModel::get_mean_at_point ( int  vertex_index) const
inline

Return the value of the mean at a given vertex index.

Parameters
[in]vertex_indexA vertex index.
Returns
A homogeneous vector containing the values at the given vertex index.
cv::Mat eos::morphablemodel::PcaModel::get_normalised_pca_basis ( ) const
inline

Returns the PCA basis matrix, i.e. the eigenvectors. Each column of the matrix is an eigenvector. The returned basis is normalised, i.e. every eigenvector is normalised by multiplying it with the square root of its eigenvalue.

Returns a clone of the matrix so that the original cannot be modified. TODO: No, don't return a clone.

Returns
Returns the normalised PCA basis matrix.
cv::Mat eos::morphablemodel::PcaModel::get_normalised_pca_basis ( int  vertex_id) const
inline

Returns the PCA basis for a particular vertex. The returned basis is normalised, i.e. every eigenvector is normalised by multiplying it with the square root of its eigenvalue.

Parameters
[in]vertex_idA vertex index. Make sure it is valid.
Returns
A Mat that points to the rows in the original basis.
int eos::morphablemodel::PcaModel::get_num_principal_components ( ) const
inline

Returns the number of principal components in the model.

Returns
The number of principal components in the model.
std::vector<std::array<int, 3> > eos::morphablemodel::PcaModel::get_triangle_list ( ) const
inline

Returns a list of triangles on how to assemble the vertices into a mesh.

Returns
The list of triangles to build a mesh.
cv::Mat eos::morphablemodel::PcaModel::get_unnormalised_pca_basis ( ) const
inline

Returns the PCA basis matrix, i.e. the eigenvectors. Each column of the matrix is an eigenvector. The returned basis is unnormalised, i.e. not scaled by their eigenvalues.

Returns a clone of the matrix so that the original cannot be modified. TODO: No, don't return a clone.

Returns
Returns the unnormalised PCA basis matrix.
cv::Mat eos::morphablemodel::PcaModel::get_unnormalised_pca_basis ( int  vertex_id) const
inline

Returns the PCA basis for a particular vertex. The returned basis is unnormalised, i.e. not scaled by their eigenvalues.

Parameters
[in]vertex_idA vertex index. Make sure it is valid.
Returns
A Mat that points to the rows in the original basis.

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