Skip to content

Commit

Permalink
Added get_shape_at_point() for (neutral) shape model only
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikhuber authored and Patrik Huber committed Jul 6, 2024
1 parent ecaa24a commit 301c98d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/eos/fitting/ceres_nonlinear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,30 @@ struct VertexColorCost
const eos::core::Image3u& image; // the observed image
};

/**
* Returns the 3D position of a single point of the 3D shape generated by the parameters given.
*
* @param[in] shape_model A PCA 3D shape model.
* @param[in] vertex_id Vertex id of the 3D model that should be projected.
* @param[in] shape_coeffs A set of PCA shape coefficients used to generate the point.
* @return The 3D point.
*/
template <typename T>
Eigen::Vector3<T> get_shape_at_point(const eos::morphablemodel::PcaModel& shape_model, int vertex_id,
Eigen::Map<const Eigen::VectorX<T>> shape_coeffs)
{
// Computing Shape = shape_mean + shape_basis*shape_coeffs:
const Eigen::Vector3f shape_mean = shape_model.get_mean_at_point(vertex_id);
// Note: We seem to have a dependent name here, so we need 'template', to help the compiler that 'cast<T>'
// is a template.
const Eigen::Vector3<T> shape_vector = shape_model.get_rescaled_pca_basis_at_point(vertex_id)
.leftCols(shape_coeffs.size())
.template cast<T>() *
shape_coeffs;

return Eigen::Vector3<T>(shape_mean.cast<T>() + shape_vector);
};

/**
* Returns the 3D position of a single point of the 3D shape generated by the parameters given.
*
Expand Down

0 comments on commit 301c98d

Please sign in to comment.