Skip to content

Commit

Permalink
Updated the eos submodule to v0.9.1
Browse files Browse the repository at this point in the history
And made all the required small code changes.
  • Loading branch information
patrikhuber committed Dec 2, 2016
1 parent 1d49b45 commit c21931e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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})
Expand Down
8 changes: 4 additions & 4 deletions apps/4dface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int main(int argc, char *argv[])
vector<int> 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);
Expand Down Expand Up @@ -259,15 +259,15 @@ 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:
Mat merged_isomap = isomap_averaging.add_and_merge(isomap);
// 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;
Expand All @@ -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);
}
Expand Down

0 comments on commit c21931e

Please sign in to comment.