Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune fit-model-ceres's cost function weights #348

Open
patrikhuber opened this issue Feb 18, 2023 · 0 comments
Open

Tune fit-model-ceres's cost function weights #348

patrikhuber opened this issue Feb 18, 2023 · 0 comments

Comments

@patrikhuber
Copy link
Owner

patrikhuber commented Feb 18, 2023

To find good weights, ceres::ResidualBlockId can be used to store the IDs to each added residual blocks. Then, one can use ceres::Problem::EvaluateOptions and ceres::Problem::Evaluate(...) to retrieve the values of each individual term. We don't do that in the example for simplicity reasons. But we should perhaps still provide adequate example weights.

patrikhuber added a commit that referenced this issue Feb 18, 2023
This means no more messing around with GLM_FORCE_UNRESTRICTED_GENTYPE. Eigen and Ceres work much nicer together.

Updated the cost functions in ceres_nonlinear.hpp, and the example fit-model.ceres:

* Renamed LandmarkCost to PerspectiveProjectionLandmarkCost
* Renamed ImageCost to VertexColorCost
* Removed the use_perspective switch - only perspective projection now.
* Passing the rotation, translation and intrinsics now as separate function/template parameters
* VertexColorCost now uses eos::core::Image instead of cv::Mat
* Added Create factory functions to the cost functions to make it easier for user code to create them (following the Ceres tutorial)
* Number of shape, blendshape and colour coefficients can now be set, though they have to be set at compile time. We could make them runtime choosable but then we'd need to use Ceres' dynamic cost functions.
* get_shape_at_point() and get_vertex_color_at_point() are now much simpler with Eigen
* Added project() and perspective() functions, equivalent to the ones in GLM
* Added eos/core/math.hpp, with functions to convert between degrees and radians (inspired by GLM)

I have not measured the performance difference between the GLM and Eigen implementations, but running the fitting now is quite fast (a few seconds with VertexColorCost). I wouldn't be surprised if it became faster.

Two notes about fit-model-ceres:
* The weights for the cost functions are not really tuned, see #348
* The contour fitting is commented out at the moment, see #349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant