Commit e2a3076a authored by Patrik Huber's avatar Patrik Huber

Merge branch 'master' into devel

parents b91727a8 154e8d80
......@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
"an input image")
("landmarks,l", po::value<fs::path>(&landmarksfile)->required()->default_value("data/image_0010.pts"),
"2D landmarks for the image, in ibug .pts format")
("mapping,p", po::value<fs::path>(&mappingsfile)->required()->default_value("../share/ibug2did.txt"),
("mapping,p", po::value<fs::path>(&mappingsfile)->required()->default_value("../share/ibug_to_sfm.txt"),
"landmark identifier to model vertex number mapping")
("output,o", po::value<fs::path>(&outputfile)->required()->default_value("out"),
"basename for the output rendering and obj files")
......
......@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
"an input image")
("landmarks,l", po::value<fs::path>(&landmarksfile)->required()->default_value("data/image_0010.pts"),
"2D landmarks for the image, in ibug .pts format")
("mapping,p", po::value<fs::path>(&mappingsfile)->required()->default_value("../share/ibug2did.txt"),
("mapping,p", po::value<fs::path>(&mappingsfile)->required()->default_value("../share/ibug_to_sfm.txt"),
"landmark identifier to model vertex number mapping")
("model-contour,c", po::value<fs::path>(&contourfile)->required()->default_value("../share/model_contours.json"),
"file with model contour indices")
......
......@@ -131,7 +131,7 @@ inline std::vector<int> occluding_boundary_vertices(const core::Mesh& mesh, cons
// Compute the face normals of the rotated mesh:
std::vector<glm::vec3> facenormals;
for (auto&& f : mesh.tvi) { // for each face (triangle):
auto n = render::compute_face_normal(rotated_vertices[f[0]], rotated_vertices[f[1]], rotated_vertices[f[2]]);
auto n = render::compute_face_normal(glm::vec3(rotated_vertices[f[0]]), glm::vec3(rotated_vertices[f[1]]), glm::vec3(rotated_vertices[f[2]]));
facenormals.push_back(n);
}
......@@ -180,7 +180,7 @@ inline std::vector<int> occluding_boundary_vertices(const core::Mesh& mesh, cons
auto& v1 = rotated_vertices[tri[1]];
auto& v2 = rotated_vertices[tri[2]];
glm::vec3 ray_origin = rotated_vertices[vertex_idx];
glm::vec3 ray_origin(rotated_vertices[vertex_idx]);
glm::vec3 ray_direction(0.0f, 0.0f, 1.0f); // we shoot the ray from the vertex towards the camera
auto intersect = ray_triangle_intersect(ray_origin, ray_direction, glm::vec3(v0), glm::vec3(v1), glm::vec3(v2), false);
// first is bool intersect, second is the distance t
......
......@@ -117,11 +117,11 @@ struct ModelContour
* This class holds 2D image contour landmark information. More specifically,
* it defines which 2D landmark IDs correspond to the right contour and which
* to the left. These definitions are loaded from a file, for example from
* the "contour_landmarks" part of share/ibug2did.txt.
* the "contour_landmarks" part of share/ibug_to_sfm.txt.
*
* Note: Better names could be ContourDefinition or ImageContourLandmarks, to
* disambiguate 3D and 2D landmarks?
* Todo: I think this should go into the LandmarkMapper. Isn't it part of ibug2did.txt already?
* Todo: I think this should go into the LandmarkMapper. Isn't it part of ibug_to_sfm.txt already?
*/
struct ContourLandmarks
{
......@@ -135,7 +135,7 @@ struct ContourLandmarks
/**
* Helper method to load contour landmarks from a text file with landmark
* mappings, like ibug2did.txt.
* mappings, like ibug_to_sfm.txt.
*
* @param[in] filename Filename to a landmark-mapping file.
* @return A ContourLandmarks instance with loaded 2D contour landmarks.
......
......@@ -232,7 +232,7 @@ inline cv::Mat extract_texture(core::Mesh mesh, cv::Mat affine_camera_matrix, cv
for (int y = min(dst_tri[0].y, min(dst_tri[1].y, dst_tri[2].y)); y < max(dst_tri[0].y, max(dst_tri[1].y, dst_tri[2].y)); ++y) {
if (detail::is_point_in_triangle(cv::Point2f(x, y), dst_tri[0], dst_tri[1], dst_tri[2])) {
// As the coordinates of the transformed pixel in the image will most likely not lie on a texel, we have to choose how to
// As the coordinates of the transformed pixel in the image will most likely not lie on a texel, we have to choose how to
// calculate the pixel colors depending on the next texels
// there are three different texture interpolation methods: area, bilinear and nearest neighbour
......@@ -408,7 +408,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat
auto& v1 = rotated_vertices[tri[1]];
auto& v2 = rotated_vertices[tri[2]];
vec3 ray_origin = vertex;
vec3 ray_origin(vertex);
vec3 ray_direction(0.0f, 0.0f, 1.0f); // we shoot the ray from the vertex towards the camera
auto intersect = fitting::ray_triangle_intersect(ray_origin, ray_direction, vec3(v0), vec3(v1),
vec3(v2), false);
......
......@@ -180,7 +180,7 @@ PYBIND11_PLUGIN(eos) {
;
py::class_<fitting::ContourLandmarks>(fitting_module, "ContourLandmarks", "Defines which 2D landmarks comprise the right and left face contour.")
.def_static("load", &fitting::ContourLandmarks::load, "Helper method to load contour landmarks from a text file with landmark mappings, like ibug2did.txt.", py::arg("filename"))
.def_static("load", &fitting::ContourLandmarks::load, "Helper method to load contour landmarks from a text file with landmark mappings, like ibug_to_sfm.txt.", py::arg("filename"))
;
py::class_<fitting::ModelContour>(fitting_module, "ModelContour", "Definition of the vertex indices that define the right and left model contour.")
......
......@@ -36,52 +36,32 @@ fwrite(f, size(bfm.shapeMU, 1), 'int32'); % num vertices times 3
fwrite(f, size(bfm.shapePC, 2), 'int32'); % number of basis vectors
% Write the shape mean:
for i=1:size(bfm.shapeMU, 1)
fwrite(f, bfm.shapeMU(i), 'float');
end
fwrite(f, bfm.shapeMU, 'float');
% Write the unnormalised shape PCA basis matrix:
% All of basis 1 will be written first, then basis 2, etc.
for basis=1:size(bfm.shapePC, 2)
for j=1:size(bfm.shapePC, 1) % all data points of the basis
fwrite(f, bfm.shapePC(j, basis), 'float');
end
end
fwrite(f, bfm.shapePC, 'float');
% Write the shape eigenvalues:
for i=1:size(bfm.shapeEV, 1)
fwrite(f, bfm.shapeEV(i), 'float');
end
fwrite(f, bfm.shapeEV, 'float');
% Write num_triangles and the triangle list:
fwrite(f, size(bfm.tl, 1), 'int32');
for i=1:size(bfm.tl, 1)
fwrite(f, bfm.tl(i, 1), 'int32');
fwrite(f, bfm.tl(i, 2), 'int32');
fwrite(f, bfm.tl(i, 3), 'int32');
end
fwrite(f, bfm.tl', 'int32');
% Now just exactly the same for the colour (albedo) model:
fwrite(f, size(bfm.texMU, 1), 'int32'); % num vertices times 3
fwrite(f, size(bfm.texPC, 2), 'int32'); % number of basis vectors
% Write the colour mean:
for i=1:size(bfm.texMU, 1)
fwrite(f, bfm.texMU(i), 'float');
end
fwrite(f, bfm.texMU, 'float');
% Write the unnormalised colour PCA basis matrix:
% All of basis 1 will be written first, then basis 2, etc.
for basis=1:size(bfm.texPC, 2)
for j=1:size(bfm.texPC, 1) % all data points of the basis
fwrite(f, bfm.texPC(j, basis), 'float');
end
end
fwrite(f, bfm.texPC, 'float');
% Write the colour eigenvalues:
for i=1:size(bfm.texEV, 1)
fwrite(f, bfm.texEV(i), 'float');
end
fwrite(f, bfm.texEV, 'float');
fclose(f);
......
; Mapping from the 68-point ibug annotations to the Surrey DID format (3DMM vertex indices).
; Mapping from the 68-point ibug annotations to the Surrey Face Model (SFM) mesh vertex indices.
; Note: Points above vertex id 845 are not defined on the reference and thus not available in all model resolutions.
landmarkMappings ; A mapping from input landmarks (ibug, lhs) to output landmarks (DID, rhs)
landmarkMappings ; A mapping from input landmarks (ibug, lhs) to output landmarks (SFM, rhs)
{
; 1 to 8 are the right contour landmarks
9 33 ; chin bottom
......
......@@ -3,7 +3,7 @@ eos: A lightweight header-only 3D Morphable Model fitting library in modern C++1
Files in this directory:
- ibug2did.txt:
- ibug_to_sfm.txt:
Mappings from the popular ibug 68-point 2D facial landmarks markup to
Surrey Face Model indices.
......@@ -33,10 +33,10 @@ Files in this directory:
model, if the points exist here.
- reference_annotated.obj:
Visualisation of the landmark points defined in the ibug2did.txt mapping file.
Visualisation of the landmark points defined in the ibug_to_sfm.txt mapping file.
* Red: Annotated ibug points that are defined on the reference shape.
* Green: Contour vertices from the file model_contours.json.
The file ibug2did.txt contains a few more mappings of landmarks that are not present
The file ibug_to_sfm.txt contains a few more mappings of landmarks that are not present
in the reference, for example the middle-inner eyebrow points - they are not visualised.
- reference_symmetry.txt:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment