patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.89k stars 596 forks source link

Setting expression in Python #266

Open Fivetuple opened 5 years ago

Fivetuple commented 5 years ago

Hi,

How do I set the facial expression using Python if the fit_shape_and_pose function does not have a blendshape_coefficients argument?

The following argument types are supported:

  1. (morphable_model: eos.morphablemodel.MorphableModel, landmarks: List[eos.core.Landmark], landmark_mapper: eos.core.LandmarkMapper, image_width: int, image_height: int, edge_topology: eos.morphablemodel.EdgeTopology, contour_landmarks: eos.fitting.ContourLandmarks, model_contour: eos.fitting.ModelContour, num_iterations: int = 5, num_shape_coefficients_to_fit: Optional[int] = None, lambda_identity: float = 30.0, num_expression_coefficients_to_fit: Optional[int] = None, lambda_expressions: Optional[float] = 30.0) -> Tuple[eos.core.Mesh, eos.fitting.RenderingParameters, List[float], List[float]]
patrikhuber commented 5 years ago

Hi,

fit_shape_and_pose(...) estimates face shape (identity & expression), so you can't set it there. The expression coefficients are a return parameter of that function.

ArisTing commented 4 years ago

Hi, I want to use starting values of expression coefficients in fitting. So can I overload the fit_shape_and_pose(...) function to set starting values for them? But how to overload in Python?

patrikhuber commented 4 years ago

Hi @ArisTing,

I would suggest that you have a look at pybind11's documentation. It should be easy to add the function to the Python bindings with the parameters that you need. Pybind11 also supports optional and default arguments.

kanonet commented 4 years ago

Hi @ArisTing, what you asked was added to my fork of eos, see the py_bindings branch: https://github.com/kanonet/eos/tree/py_bindings maybe you can use this changes for your project? Once @patrikhuber reviews my other PRs I plan to also suggest my pybind additions to get accepted here.