This class represents a PCA-model that consists of:
More...
#include <PcaModel.hpp>
This class represents a PCA-model that consists of:
- a mean vector (y x z)
- a PCA basis matrix (unnormalised and normalised)
- a PCA variance vector.
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.
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] | mean | The mean used to build the PCA model. |
[in] | pca_basis | The PCA basis (eigenvectors), normalised (multiplied by the eigenvalues). |
[in] | eigenvalues | The eigenvalues used to build the PCA model. |
[in] | triangle_list | An index list of how to assemble the mesh. |
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] | sigma | The 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] | coefficients | The 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] | index | The 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_index | A 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_id | A 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_id | A 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: