From c21931e9b75d3b659687c84dbacd87c3ca541c11 Mon Sep 17 00:00:00 2001 From: Patrik Huber Date: Fri, 2 Dec 2016 17:58:13 +0000 Subject: [PATCH] Updated the eos submodule to v0.9.1 And made all the required small code changes. --- CMakeLists.txt | 2 ++ apps/4dface.cpp | 8 ++++---- external/eos | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd79c98..afa7a4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ set(superviseddescent_INCLUDE_DIR "${superviseddescent_DIR}/include") set(cereal_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/external/eos/3rdparty/cereal-1.1.1/include") set(glm_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/external/eos/3rdparty/glm") set(nanoflann_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/external/eos/3rdparty/nanoflann/include") +set(eigen3_nnls_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/external/eos/3rdparty/eigen3-nnls/src") # The new model is not in the repository, download it manually for now: if(NOT EXISTS "face_landmarks_model_rcr_68.bin") @@ -108,6 +109,7 @@ include_directories(${eos_INCLUDE_DIR}) include_directories(${cereal_INCLUDE_DIR}) include_directories(${glm_INCLUDE_DIR}) include_directories(${nanoflann_INCLUDE_DIR}) +include_directories(${eigen3_nnls_INCLUDE_DIR}) add_executable(4dface apps/4dface.cpp apps/helpers.hpp) target_link_libraries(4dface ${OpenCV_LIBS} ${Boost_LIBRARIES}) diff --git a/apps/4dface.cpp b/apps/4dface.cpp index 5c5c6d4..6bd48aa 100644 --- a/apps/4dface.cpp +++ b/apps/4dface.cpp @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) vector vertex_indices_contour; // For each 2D contour landmark, get the corresponding 3D vertex point and vertex id: auto yaw_angle = glm::degrees(glm::eulerAngles(rendering_params.get_rotation())[1]); - std::tie(image_points_contour, model_points_contour, vertex_indices_contour) = fitting::get_contour_correspondences(rcr_to_eos_landmark_collection(current_landmarks), ibug_contour, model_contour, yaw_angle, morphable_model, rendering_params.get_modelview(), rendering_params.get_projection(), fitting::get_opencv_viewport(frame.cols, frame.rows)); + std::tie(image_points_contour, model_points_contour, vertex_indices_contour) = fitting::get_contour_correspondences(rcr_to_eos_landmark_collection(current_landmarks), ibug_contour, model_contour, yaw_angle, morphable_model.get_mean(), rendering_params.get_modelview(), rendering_params.get_projection(), fitting::get_opencv_viewport(frame.cols, frame.rows)); // Add the contour correspondences to the set of landmarks that we use for the fitting: model_points = concat(model_points, model_points_contour); vertex_indices = concat(vertex_indices, vertex_indices_contour); @@ -259,7 +259,7 @@ int main(int argc, char *argv[]) draw_axes_topright(glm::eulerAngles(rendering_params.get_rotation())[0], glm::eulerAngles(rendering_params.get_rotation())[1], glm::eulerAngles(rendering_params.get_rotation())[2], frame); // Get the fitted mesh, extract the texture: - render::Mesh mesh = morphablemodel::detail::sample_to_mesh(shape_instance, morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); + render::Mesh mesh = morphablemodel::sample_to_mesh(shape_instance, morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); Mat isomap = render::extract_texture(mesh, affine_cam, unmodified_frame, true, render::TextureInterpolation::NearestNeighbour, 512); // Merge the isomaps - add the current one to the already merged ones: @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) // Same for the shape: shape_coefficients = pca_shape_merging.add_and_merge(shape_coefficients); auto merged_shape = morphable_model.get_shape_model().draw_sample(shape_coefficients) + morphablemodel::to_matrix(blendshapes) * Mat(blendshape_coefficients); - render::Mesh merged_mesh = morphablemodel::detail::sample_to_mesh(merged_shape, morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); + render::Mesh merged_mesh = morphablemodel::sample_to_mesh(merged_shape, morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); // Render the model in a separate window using the estimated pose, shape and merged texture: Mat rendering; @@ -286,7 +286,7 @@ int main(int argc, char *argv[]) } if (key == 's') { // save an obj + current merged isomap to the disk: - render::Mesh neutral_expression = morphablemodel::detail::sample_to_mesh(morphable_model.get_shape_model().draw_sample(shape_coefficients), morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); + render::Mesh neutral_expression = morphablemodel::sample_to_mesh(morphable_model.get_shape_model().draw_sample(shape_coefficients), morphable_model.get_color_model().get_mean(), morphable_model.get_shape_model().get_triangle_list(), morphable_model.get_color_model().get_triangle_list(), morphable_model.get_texture_coordinates()); render::write_textured_obj(neutral_expression, "current_merged.obj"); cv::imwrite("current_merged.isomap.png", merged_isomap); } diff --git a/external/eos b/external/eos index afe6300..dc84b9a 160000 --- a/external/eos +++ b/external/eos @@ -1 +1 @@ -Subproject commit afe6300812bc9e822742cb5814f2fc327397256a +Subproject commit dc84b9ae2b93dcfee097890772a7c07241834b17