Skip to content

Commit 519eb35

Browse files
committed
Remove blendshapes argument from fit_shape_and_pose in Python
It was unused and caused a bad optional access because the expression model wasn't passed in. Updated the demo.py script accordingly.
1 parent 80e4c17 commit 519eb35

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

python/demo.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ def main():
1010

1111
model = eos.morphablemodel.load_model("../share/sfm_shape_3448.bin")
1212
blendshapes = eos.morphablemodel.load_blendshapes("../share/expression_blendshapes_3448.bin")
13+
# Create a MorphableModel with expressions from the loaded neutral model and blendshapes:
14+
morphablemodel_with_expressions = eos.morphablemodel.MorphableModel(model.get_shape_model(), blendshapes,
15+
eos.morphablemodel.PcaModel(),
16+
model.get_texture_coordinates())
1317
landmark_mapper = eos.core.LandmarkMapper('../share/ibug_to_sfm.txt')
1418
edge_topology = eos.morphablemodel.load_edge_topology('../share/sfm_3448_edge_topology.json')
1519
contour_landmarks = eos.fitting.ContourLandmarks.load('../share/ibug_to_sfm.txt')
1620
model_contour = eos.fitting.ModelContour.load('../share/sfm_model_contours.json')
1721

18-
(mesh, pose, shape_coeffs, blendshape_coeffs) = eos.fitting.fit_shape_and_pose(model, blendshapes,
19-
landmarks, landmark_ids, landmark_mapper,
20-
image_width, image_height, edge_topology, contour_landmarks, model_contour)
22+
(mesh, pose, shape_coeffs, blendshape_coeffs) = eos.fitting.fit_shape_and_pose(morphablemodel_with_expressions,
23+
landmarks, landmark_ids, landmark_mapper, image_width, image_height, edge_topology, contour_landmarks, model_contour)
2124

2225
# Now you can use your favourite plotting/rendering library to display the fitted mesh, using the rendering
2326
# parameters in the 'pose' variable.

python/generate-python-bindings.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ PYBIND11_MODULE(eos, eos_module)
247247
fitting_module.def(
248248
"fit_shape_and_pose",
249249
[](const morphablemodel::MorphableModel& morphable_model,
250-
const std::vector<morphablemodel::Blendshape>& blendshapes,
251250
const std::vector<Eigen::Vector2f>& landmarks, const std::vector<std::string>& landmark_ids,
252251
const core::LandmarkMapper& landmark_mapper, int image_width, int image_height,
253252
const morphablemodel::EdgeTopology& edge_topology,
@@ -274,8 +273,8 @@ PYBIND11_MODULE(eos, eos_module)
274273
},
275274
"Fit the pose (camera), shape model, and expression blendshapes to landmarks, in an iterative way. "
276275
"Returns a tuple (mesh, rendering_parameters, shape_coefficients, blendshape_coefficients).",
277-
py::arg("morphable_model"), py::arg("blendshapes"), py::arg("landmarks"), py::arg("landmark_ids"),
278-
py::arg("landmark_mapper"), py::arg("image_width"), py::arg("image_height"), py::arg("edge_topology"),
276+
py::arg("morphable_model"), py::arg("landmarks"), py::arg("landmark_ids"), py::arg("landmark_mapper"),
277+
py::arg("image_width"), py::arg("image_height"), py::arg("edge_topology"),
279278
py::arg("contour_landmarks"), py::arg("model_contour"), py::arg("num_iterations") = 5,
280279
py::arg("num_shape_coefficients_to_fit") = py::none(), py::arg("lambda_identity") = 30.0f,
281280
py::arg("num_expression_coefficients_to_fit") = py::none(), py::arg("lambda_expressions") = 30.0f);

0 commit comments

Comments
 (0)