Functionality to represent a Morphable Model, its PCA models, and functions to load models and blendshapes.
More...
|
| std::vector< Blendshape > | load_blendshapes (std::string filename) |
| |
| void | save_blendshapes (const std::vector< Blendshape > &blendshapes, std::string filename) |
| |
| Eigen::MatrixXf | to_matrix (const std::vector< Blendshape > &blendshapes) |
| | Copies the blendshapes into a matrix, with each column being a blendshape.
|
| |
| Eigen::Map< const Eigen::VectorXf > | to_vector (const std::vector< float > &coefficients) |
| | Maps an std::vector of coefficients with Eigen::Map, so it can be multiplied with a blendshapes matrix.
|
| |
| void | save_coefficients (std::vector< float > coefficients, std::string filename) |
| |
| std::vector< float > | load_coefficients (std::string filename) |
| |
| void | save_edge_topology (EdgeTopology edge_topology, std::string filename) |
| |
| EdgeTopology | load_edge_topology (std::string filename) |
| |
| Eigen::VectorXf | draw_sample (const ExpressionModel &expression_model, std::vector< float > expression_coefficients) |
| |
| std::vector< std::array< double, 2 > > | load_isomap (std::string isomap_file) |
| |
| MorphableModel | load_scm_model (std::string model_filename, cpp17::optional< std::string > isomap_file=cpp17::nullopt) |
| |
| core::Mesh | sample_to_mesh (const Eigen::VectorXf &shape_instance, const Eigen::VectorXf &color_instance, const std::vector< std::array< int, 3 > > &tvi, const std::vector< std::array< int, 3 > > &tci, const std::vector< std::array< double, 2 > > &texture_coordinates=std::vector< std::array< double, 2 > >(), const std::vector< std::array< int, 3 > > &texture_triangle_indices=std::vector< std::array< int, 3 > >()) |
| |
| MorphableModel | load_model (std::string filename) |
| |
| void | save_model (MorphableModel model, std::string filename) |
| |
| Eigen::MatrixXf | rescale_pca_basis (const Eigen::MatrixXf &orthonormal_basis, const Eigen::VectorXf &eigenvalues) |
| |
| Eigen::MatrixXf | normalise_pca_basis (const Eigen::MatrixXf &rescaled_basis, const Eigen::VectorXf &eigenvalues) |
| |
| PcaModel | load_pca_model (std::string filename) |
| |
| void | save_pca_model (PcaModel model, std::string filename) |
| |
Functionality to represent a Morphable Model, its PCA models, and functions to load models and blendshapes.
| MorphableModel eos::morphablemodel::load_scm_model |
( |
std::string |
model_filename, |
|
|
cpp17::optional< std::string > |
isomap_file = cpp17::nullopt |
|
) |
| |
|
inline |
Load a shape and color model from a .scm file containing a Morphable Model in the Surrey format. CVSSP's software internally trains and stores the model in this custom binary format and this class provides means to load them.
Note on multi-resolution models: The landmarks to vertex-id mapping is always the same. The lowest resolution model has all the landmarks defined and for the higher resolutions, the mesh is divided from that on. Note: For new landmarks we add, this might not be the case if we add them in the highest resolution model, so take care!
For the optional isomap_file, a text file along the lines of 'IsoMnF_Ar2.txt' or 'isomap.txt' from CVSSP can be given.
The PCA basis matrix stored in the file and loaded is the orthogonal PCA basis, i.e. it is not normalised by the eigenvalues.
- Parameters
-
| [in] | model_filename | A binary .scm-file containing the model. |
| [in] | isomap_file | An optional path to a text file containing texture coordinates. |
- Returns
- The Morphable Model loaded from the file.
- Exceptions
-
| std::runtime_error | when reading either of the files fails. |
| core::Mesh eos::morphablemodel::sample_to_mesh |
( |
const Eigen::VectorXf & |
shape_instance, |
|
|
const Eigen::VectorXf & |
color_instance, |
|
|
const std::vector< std::array< int, 3 > > & |
tvi, |
|
|
const std::vector< std::array< int, 3 > > & |
tci, |
|
|
const std::vector< std::array< double, 2 > > & |
texture_coordinates, |
|
|
const std::vector< std::array< int, 3 > > & |
texture_triangle_indices |
|
) |
| |
|
inline |
Helper function that creates a Mesh from given shape and colour PCA instances. Needs the vertex index lists as well to assemble the mesh - and optional texture coordinates.
If color_instance is empty, it will create a mesh without vertex colouring. Colour values are assumed to be in the range [0, 1] and will be clamped to [0, 1].
- Parameters
-
| [in] | shape_instance | PCA shape model instance. |
| [in] | color_instance | PCA colour model instance. |
| [in] | tvi | Triangle vertex indices. |
| [in] | tci | Triangle colour indices (usually identical to the vertex indices). |
| [in] | texture_coordinates | Optional texture coordinates for each vertex. |
| [in] | texture_triangle_indices | Optional triangulation for the texture coordinates. |
- Returns
- A mesh created from given parameters.