eos 1.4.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
eos::morphablemodel::MorphableModel Class Reference

A class representing a 3D Morphable Model, consisting of a shape- and colour (albedo) PCA model. More...

#include <MorphableModel.hpp>

Public Types

enum class  ExpressionModelType { None , Blendshapes , PcaModel }
 The type of the expression model that this MorphableModel contains. More...
 

Public Member Functions

 MorphableModel (PcaModel shape_model, PcaModel color_model, cpp17::optional< std::unordered_map< std::string, int > > landmark_definitions=cpp17::nullopt, std::vector< std::array< double, 2 > > texture_coordinates=std::vector< std::array< double, 2 > >(), std::vector< std::array< int, 3 > > texture_triangle_indices=std::vector< std::array< int, 3 > >())
 
 MorphableModel (PcaModel shape_model, ExpressionModel expression_model, PcaModel color_model, cpp17::optional< std::unordered_map< std::string, int > > landmark_definitions=cpp17::nullopt, std::vector< std::array< double, 2 > > texture_coordinates=std::vector< std::array< double, 2 > >(), std::vector< std::array< int, 3 > > texture_triangle_indices=std::vector< std::array< int, 3 > >())
 
const PcaModelget_shape_model () const
 
const PcaModelget_color_model () const
 
const auto & get_expression_model () const
 
core::Mesh get_mean () const
 
template<class RNG >
core::Mesh draw_sample (RNG &engine, float shape_sigma=1.0f, float color_sigma=1.0f) const
 
core::Mesh draw_sample (std::vector< float > shape_coefficients, std::vector< float > color_coefficients) const
 
core::Mesh draw_sample (std::vector< float > shape_coefficients, std::vector< float > expression_coefficients, std::vector< float > color_coefficients) const
 
bool has_color_model () const
 
bool has_separate_expression_model () const
 
const auto & get_landmark_definitions () const
 
const std::vector< std::array< double, 2 > > & get_texture_coordinates () const
 
const std::vector< std::array< int, 3 > > & get_texture_triangle_indices () const
 
ExpressionModelType get_expression_model_type () const
 

Friends

class cereal::access
 

Detailed Description

A class representing a 3D Morphable Model, consisting of a shape- and colour (albedo) PCA model.

For the general idea of 3DMMs see T. Vetter, V. Blanz, 'A Morphable Model for the Synthesis of 3D Faces', SIGGRAPH 1999.

Member Enumeration Documentation

◆ ExpressionModelType

The type of the expression model that this MorphableModel contains.

A MorphableModel can contain no expression model, an expression model consisting of blendshapes, or a PCA model of expressions.

Constructor & Destructor Documentation

◆ MorphableModel() [1/2]

eos::morphablemodel::MorphableModel::MorphableModel ( PcaModel  shape_model,
PcaModel  color_model,
cpp17::optional< std::unordered_map< std::string, int > >  landmark_definitions = cpp17::nullopt,
std::vector< std::array< double, 2 > >  texture_coordinates = std::vector<std::array<double, 2>>(),
std::vector< std::array< int, 3 > >  texture_triangle_indices = std::vector<std::array<int, 3>>() 
)
inline

Create a Morphable Model from a shape and a colour PCA model, and optional texture coordinates.

Parameters
[in]shape_modelA PCA model over the shape.
[in]color_modelA PCA model over the colour (albedo).
[in]landmark_definitionsA set of landmark definitions, mapping from identifiers to vertex numbers.
[in]texture_coordinatesOptional texture coordinates for every vertex.
[in]texture_triangle_indicesOptional triangulation for the texture coordinates.

◆ MorphableModel() [2/2]

eos::morphablemodel::MorphableModel::MorphableModel ( PcaModel  shape_model,
ExpressionModel  expression_model,
PcaModel  color_model,
cpp17::optional< std::unordered_map< std::string, int > >  landmark_definitions = cpp17::nullopt,
std::vector< std::array< double, 2 > >  texture_coordinates = std::vector<std::array<double, 2>>(),
std::vector< std::array< int, 3 > >  texture_triangle_indices = std::vector<std::array<int, 3>>() 
)
inline

Create a Morphable Model from a shape and a colour PCA model, an expression PCA model or blendshapes, and optional texture coordinates.

Parameters
[in]shape_modelA PCA model over the shape.
[in]expression_modelA PCA model over expressions, or a set of blendshapes.
[in]color_modelA PCA model over the colour (albedo).
[in]landmark_definitionsA set of landmark definitions, mapping from identifiers to vertex numbers.
[in]texture_coordinatesOptional texture coordinates for every vertex.
[in]texture_triangle_indicesOptional triangulation for the texture coordinates.

Member Function Documentation

◆ draw_sample() [1/3]

template<class RNG >
core::Mesh eos::morphablemodel::MorphableModel::draw_sample ( RNG &  engine,
float  shape_sigma = 1.0f,
float  color_sigma = 1.0f 
) const
inline

Draws a random sample from the model, where the coefficients for the shape- and colour models are both drawn from a standard normal (or with the given standard deviation).

If the Morphable Model is a shape-only model, the returned mesh will not contain any colour data.

Parameters
[in]engineRandom number engine used to draw random coefficients.
[in]shape_sigmaThe shape model standard deviation.
[in]color_sigmaThe colour model standard deviation.
Returns
A random sample from the model.

◆ draw_sample() [2/3]

core::Mesh eos::morphablemodel::MorphableModel::draw_sample ( std::vector< float >  shape_coefficients,
std::vector< float >  color_coefficients 
) const
inline

Returns a sample from the model with the given shape and colour PCA coefficients.

If one of the given vectors is empty, the mean is used. The coefficient vectors should contain normalised, i.e. standard normal distributed coefficients. If the Morphable Model is a shape-only model (without colour model), make sure to leave color_coefficients empty. If a partial coefficient vector is given, it is filled with zeros up to the end.

Parameters
[in]shape_coefficientsThe PCA coefficients used to generate the shape sample.
[in]color_coefficientsThe PCA coefficients used to generate the vertex colouring.
Returns
A model instance with given coefficients.

◆ draw_sample() [3/3]

core::Mesh eos::morphablemodel::MorphableModel::draw_sample ( std::vector< float >  shape_coefficients,
std::vector< float >  expression_coefficients,
std::vector< float >  color_coefficients 
) const
inline

Returns a sample from the model with the given shape, expression and colour PCA coefficients.

If you call this method on a MorphableModel that doesn't contain an expression model, it'll throw an exception. If one of the given vectors is empty, the mean is used. The coefficient vectors should contain normalised, i.e. standard normal distributed coefficients. If the Morphable Model is a shape-only model (without colour model), make sure to leave color_coefficients empty. If a partial coefficient vector is given, it is filled with zeros up to the end.

Parameters
[in]shape_coefficientsThe PCA coefficients used to generate the shape sample.
[in]expression_coefficientsThe PCA coefficients used to generate the expression sample.
[in]color_coefficientsThe PCA coefficients used to generate the vertex colouring.
Returns
A model instance with given coefficients.

◆ get_color_model()

const PcaModel & eos::morphablemodel::MorphableModel::get_color_model ( ) const
inline

Returns the PCA colour (albedo) model of this Morphable Model.

Returns
The colour model.

◆ get_expression_model()

const auto & eos::morphablemodel::MorphableModel::get_expression_model ( ) const
inline

Returns the shape expression model, if this Morphable Model has one.

Returns an empty cpp17::optional if the Morphable Model does not have a separate expression model (check with MorphableModel::has_separate_expression_model()). If it does have an expression model, an std::variant<PcaModel, Blendshapes> is returned - that is, either a PcaModel (if it is an expression PCA model), or Blendshapes.

Returns
The expression model or an empty optional.

◆ get_expression_model_type()

ExpressionModelType eos::morphablemodel::MorphableModel::get_expression_model_type ( ) const
inline

Returns the type of the expression model: None, Blendshapes or PcaModel.

Returns
The type of the expression model.

◆ get_landmark_definitions()

const auto & eos::morphablemodel::MorphableModel::get_landmark_definitions ( ) const
inline

Returns the landmark definitions for this Morphable Model, which might be an empty optional, if the model doesn't contain any.

The landmark definitions are define mappings from a set of global landmark identifiers, like for example "eye.right.outer_corner", to the model's respective vertex indices. A MorphableModel may or may not contain these landmark definitions, depending on how it was created.

Returns
The landmark definitions of this MorphableModel.

◆ get_mean()

core::Mesh eos::morphablemodel::MorphableModel::get_mean ( ) const
inline

Returns the mean of the shape (identity, and expressions, if present) and colour model as a Mesh.

If the model contains a separate PCA expression model, the mean of that model is added and the overall shape mean is returned.

Returns
An mesh instance of the mean of the Morphable Model.

◆ get_shape_model()

const PcaModel & eos::morphablemodel::MorphableModel::get_shape_model ( ) const
inline

Returns the PCA shape model of this Morphable Model.

Returns
The shape model.

◆ get_texture_coordinates()

const std::vector< std::array< double, 2 > > & eos::morphablemodel::MorphableModel::get_texture_coordinates ( ) const
inline

Returns the texture coordinates for all the vertices in the model.

Returns
The texture coordinates for the model vertices.

◆ get_texture_triangle_indices()

const std::vector< std::array< int, 3 > > & eos::morphablemodel::MorphableModel::get_texture_triangle_indices ( ) const
inline

Returns the triangulation (the triangles that make up the uv mapping) for the texture coordinates.

Returns
The triangulation for the texture coordinates.

◆ has_color_model()

bool eos::morphablemodel::MorphableModel::has_color_model ( ) const
inline

Returns true if this Morphable Model contains a colour model. Returns false if it is a shape-only model.

Returns
True if the Morphable Model has a colour model (i.e. is not a shape-only model).

◆ has_separate_expression_model()

bool eos::morphablemodel::MorphableModel::has_separate_expression_model ( ) const
inline

Returns true if this Morphable Model contains a separate expression model, in the form of a PcaModel or Blendshapes.

Returns
True if the Morphable Model has a separate expression model.

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