Skip to content

Commit

Permalink
Removed glm from Ceres fitting, and rewrote it using Eigen.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
patrikhuber committed Feb 18, 2023
1 parent e79da91 commit d101ca5
Show file tree
Hide file tree
Showing 4 changed files with 507 additions and 450 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ set(HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/core/read_obj.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/core/write_obj.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/core/Rect.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/core/math.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/morphablemodel/PcaModel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/morphablemodel/MorphableModel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/morphablemodel/Blendshape.hpp
Expand Down
Loading

0 comments on commit d101ca5

Please sign in to comment.