* @return An mesh instance of the mean of the Morphable Model.
* @return An mesh instance of the mean of the Morphable Model.
*/
*/
render::Meshget_mean()const
core::Meshget_mean()const
{
{
assert(shape_model.get_data_dimension()==color_model.get_data_dimension()||!has_color_model());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(shape_model.get_data_dimension()==color_model.get_data_dimension()||!has_color_model());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(shape_model.get_data_dimension()==color_model.get_data_dimension());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models.
assert(shape_model.get_data_dimension()==color_model.get_data_dimension());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models.
assert(shape_model.get_data_dimension()==color_model.get_data_dimension()||!has_color_model());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(shape_model.get_data_dimension()==color_model.get_data_dimension()||!has_color_model());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(shape_instance.rows==color_instance.rows||color_instance.empty());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(shape_instance.rows==color_instance.rows||color_instance.empty());// The number of vertices (= model.getDataDimension() / 3) has to be equal for both models, or, alternatively, it has to be a shape-only model.
assert(mesh.vertices.size()==mesh.colors.size()||mesh.colors.empty());// The number of vertices has to be equal for both shape and colour, or, alternatively, it has to be a shape-only model.
assert(mesh.vertices.size()==mesh.colors.size()||mesh.colors.empty());// The number of vertices has to be equal for both shape and colour, or, alternatively, it has to be a shape-only model.
//assert(mesh.vertices.size() == mesh.texcoords.size() || mesh.texcoords.empty()); // same for the texcoords
//assert(mesh.vertices.size() == mesh.texcoords.size() || mesh.texcoords.empty()); // same for the texcoords
py::modulecore_module=eos_module.def_submodule("core","Essential functions and classes to work with 3D face models and landmarks.");
py::modulecore_module=eos_module.def_submodule("core","Essential functions and classes to work with 3D face models and landmarks.");
py::class_<core::LandmarkMapper>(core_module,"LandmarkMapper","Represents a mapping from one kind of landmarks to a different format(e.g.model vertices).")
py::class_<core::LandmarkMapper>(core_module,"LandmarkMapper","Represents a mapping from one kind of landmarks to a different format(e.g.model vertices).")
.def(py::init<>(),"Constructs a new landmark mapper that performs an identity mapping, that is, its output is the same as the input.")
.def(py::init<>(),"Constructs a new landmark mapper that performs an identity mapping, that is, its output is the same as the input.")
.def("__init__",[](core::LandmarkMapper&instance,std::stringfilename){// wrap the fs::path c'tor with std::string
.def("__init__",[](core::LandmarkMapper&instance,std::stringfilename){// wrap the fs::path c'tor with std::string
new(&instance)core::LandmarkMapper(filename);
new(&instance)core::LandmarkMapper(filename);
},"Constructs a new landmark mapper from a file containing mappings from one set of landmark identifiers to another.")
},"Constructs a new landmark mapper from a file containing mappings from one set of landmark identifiers to another.",py::arg("filename"))
// We can't expose the convert member function yet - need std::optional (or some trick with self/this and a lambda)
// We can't expose the convert member function yet - need std::optional (or some trick with self/this and a lambda)
;
;
py::class_<core::Mesh>(core_module,"Mesh","This class represents a 3D mesh consisting of vertices, vertex colour information and texture coordinates.")
.def("get_color_model",[](constmorphablemodel::MorphableModel&m){returnm.get_color_model();},"Returns the PCA colour (albedo) model of this Morphable Model.")
.def("get_color_model",[](constmorphablemodel::MorphableModel&m){returnm.get_color_model();},"Returns the PCA colour (albedo) model of this Morphable Model.")
;
;
morphablemodel_module.def("load_model",&morphablemodel::load_model,"Load a Morphable Model from a cereal::BinaryInputArchive (.bin) from the harddisk.");
morphablemodel_module.def("load_model",&morphablemodel::load_model,"Load a Morphable Model from a cereal::BinaryInputArchive (.bin) from the harddisk.",py::arg("filename"));
/**
/**
* - Blendshape
* - Blendshape
* - load_blendshapes()
* - load_blendshapes()
* - draw_sample()
*/
*/
py::class_<morphablemodel::Blendshape>(morphablemodel_module,"Blendshape","A class representing a 3D blendshape.")
py::class_<morphablemodel::Blendshape>(morphablemodel_module,"Blendshape","A class representing a 3D blendshape.")
.def_readwrite("name",&morphablemodel::Blendshape::name,"Name of the blendshape.")
.def_readwrite("name",&morphablemodel::Blendshape::name,"Name of the blendshape.")
.def_readwrite("deformation",&morphablemodel::Blendshape::deformation,"A 3m x 1 col-vector (xyzxyz...)', where m is the number of model-vertices. Has the same format as PcaModel::mean.")
.def_readwrite("deformation",&morphablemodel::Blendshape::deformation,"A 3m x 1 col-vector (xyzxyz...)', where m is the number of model-vertices. Has the same format as PcaModel::mean.")
;
;
morphablemodel_module.def("load_blendshapes",&morphablemodel::load_blendshapes,"Load a file with blendshapes from a cereal::BinaryInputArchive (.bin) from the harddisk.");
morphablemodel_module.def("load_blendshapes",&morphablemodel::load_blendshapes,"Load a file with blendshapes from a cereal::BinaryInputArchive (.bin) from the harddisk.",py::arg("filename"));
},"Draws a sample with given shape, blendshape and colour coeffs, and returns a mesh.",py::arg("morphable_model"),py::arg("blendshapes"),py::arg("shape_coefficients"),py::arg("blendshape_coefficients"),py::arg("color_coefficients"));
/**
/**
* - EdgeTopology
* - EdgeTopology
...
@@ -106,22 +135,7 @@ PYBIND11_PLUGIN(eos) {
...
@@ -106,22 +135,7 @@ PYBIND11_PLUGIN(eos) {
*/
*/
py::class_<morphablemodel::EdgeTopology>(morphablemodel_module,"EdgeTopology","A struct containing a 3D shape model's edge topology.");
py::class_<morphablemodel::EdgeTopology>(morphablemodel_module,"EdgeTopology","A struct containing a 3D shape model's edge topology.");
morphablemodel_module.def("load_edge_topology",&morphablemodel::load_edge_topology,"Load a 3DMM edge topology file from a json file.");
morphablemodel_module.def("load_edge_topology",&morphablemodel::load_edge_topology,"Load a 3DMM edge topology file from a json file.",py::arg("filename"));
/**
* Bindings for the eos::render namespace:
* (Note: Defining Mesh before using it below in fitting::fit_shape_and_pose)
* - Mesh
*/
py::modulerender_module=eos_module.def_submodule("render","3D mesh and texture extraction functionality.");
py::class_<render::Mesh>(render_module,"Mesh","This class represents a 3D mesh consisting of vertices, vertex colour information and texture coordinates.")
py::class_<fitting::ContourLandmarks>(fitting_module,"ContourLandmarks","Defines which 2D landmarks comprise the right and left face contour.")
py::class_<fitting::ContourLandmarks>(fitting_module,"ContourLandmarks","Defines which 2D landmarks comprise the right and left face contour.")
.def_static("load",&fitting::ContourLandmarks::load,"Helper method to load contour landmarks from a text file with landmark mappings, like ibug2did.txt.")
.def_static("load",&fitting::ContourLandmarks::load,"Helper method to load contour landmarks from a text file with landmark mappings, like ibug2did.txt.",py::arg("filename"))
;
;
py::class_<fitting::ModelContour>(fitting_module,"ModelContour","Definition of the vertex indices that define the right and left model contour.")
py::class_<fitting::ModelContour>(fitting_module,"ModelContour","Definition of the vertex indices that define the right and left model contour.")
.def_static("load",&fitting::ModelContour::load,"Helper method to load a ModelContour from a json file from the hard drive.")
.def_static("load",&fitting::ModelContour::load,"Helper method to load a ModelContour from a json file from the hard drive.",py::arg("filename"))
},"Extracts the texture of the face from the given image and stores it as isomap (a rectangular texture map).",py::arg("mesh"),py::arg("rendering_params"),py::arg("image"),py::arg("compute_view_angle")=false,py::arg("isomap_resolution")=512);
},"Extracts the texture of the face from the given image and stores it as isomap (a rectangular texture map).",py::arg("mesh"),py::arg("rendering_params"),py::arg("image"),py::arg("compute_view_angle")=false,py::arg("isomap_resolution")=512);