Skip to content

Commit

Permalink
Changed texture map output file from <filename>.isomap.png to <filena…
Browse files Browse the repository at this point in the history
…me>.texture.png

Texture map is the more generic name, and it's only really an isomap when using the SFM's texture coordinates.
Changed this in `write_textured_obj(...)` as well as in the example apps.
Improved the documentation of the Python bindings of `write_textured_obj(...)`.
  • Loading branch information
patrikhuber committed May 8, 2020
1 parent 6325e3d commit 174a2c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions examples/fit-model-multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,21 @@ int main(int argc, char *argv[])

cv::Mat texturemap_opencv = core::to_mat(texturemap);

// And save the isomap:
outputfile.replace_extension(".isomap.png");
// And save the texture map:
outputfile.replace_extension(".texture.png");
cv::imwrite(outputfile.string(), texturemap_opencv);

// Merge the isomaps:
// Merge the texture maps:
merged_texturemap = texturemap_averaging.add_and_merge(texturemap_opencv);
}

// Save the merged isomap:
// Save the merged texture map:
fs::path outputfile = outputfilebase;
outputfile += fs::path("merged.isomap.png");
outputfile += fs::path("merged.texture.png");
cv::imwrite(outputfile.string(), merged_texturemap);
outputfile.replace_extension("");

// Save the frontal rendering with merged isomap:
// Save the frontal rendering with merged texture:
core::Image4u frontal_rendering;
glm::mat4 modelview_frontal = glm::mat4(1.0);
core::Mesh neutral_expression = morphablemodel::sample_to_mesh(
Expand All @@ -340,7 +340,7 @@ int main(int argc, char *argv[])
core::write_textured_obj(morphable_model.draw_sample(pca_shape_coefficients, std::vector<float>()),
outputfile.string());

cout << "Finished fitting and wrote result mesh and isomap to files with basename " << outputfilebase
cout << "Finished fitting and wrote result mesh and texture to files with basename " << outputfilebase
<< "." << endl;

return EXIT_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions examples/fit-model-simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ int main(int argc, char* argv[])
fs::path outputfile = outputbasename + ".obj";
core::write_textured_obj(mesh, outputfile.string());

// And save the isomap:
outputfile.replace_extension(".isomap.png");
// And save the texture map:
outputfile.replace_extension(".texture.png");
cv::imwrite(outputfile.string(), core::to_mat(texturemap));

cout << "Finished fitting and wrote result mesh and isomap to files with basename "
cout << "Finished fitting and wrote result mesh and texture to files with basename "
<< outputfile.stem().stem() << "." << endl;

return EXIT_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions examples/fit-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ int main(int argc, char* argv[])
outputfile.replace_extension(".obj");
core::write_textured_obj(mesh, outputfile.string());

// And save the isomap:
outputfile.replace_extension(".isomap.png");
// And save the texture map:
outputfile.replace_extension(".texture.png");
cv::imwrite(outputfile.string(), core::to_mat(texturemap));

cout << "Finished fitting and wrote result mesh and isomap to files with basename "
cout << "Finished fitting and wrote result mesh and texture to files with basename "
<< outputfile.stem().stem() << "." << endl;

return EXIT_SUCCESS;
Expand Down
16 changes: 8 additions & 8 deletions include/eos/core/write_obj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* File: include/eos/core/write_obj.hpp
*
* Copyright 2017-2019 Patrik Huber
* Copyright 2017-2020 Patrik Huber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -102,12 +102,12 @@ inline void write_obj(const Mesh& mesh, std::string filename)
}

/**
* @brief Writes an obj file of the given Mesh, including texture coordinates,
* and an mtl file containing a reference to the isomap.
* @brief Writes an obj file of the given Mesh, including texture coordinates, and an mtl file containing a
* reference to the texture map.
*
* The obj will contain texture coordinates for the mesh, and the
* mtl file will link to a file named <filename>.isomap.png.
* Note that the texture (isomap) has to be saved separately.
* The obj will contain texture coordinates for the mesh, and the mtl file will link to a file named
* <filename>.texture.png.
* Note that the texture (i.e. the <filename>.texture.png file) has to be saved separately.
*
* @param[in] mesh The mesh to save as obj.
* @param[in] filename Output filename, including .obj.
Expand Down Expand Up @@ -192,8 +192,8 @@ inline void write_textured_obj(const Mesh& mesh, std::string filename)

std::ofstream mtl_file(mtl_filename);
std::string texture_filename(filename);
// replace '.obj' at the end with '.isomap.png':
texture_filename.replace(std::end(texture_filename) - 4, std::end(texture_filename), ".isomap.png");
// replace '.obj' at the end with '.texture.png':
texture_filename.replace(std::end(texture_filename) - 4, std::end(texture_filename), ".texture.png");

mtl_file << "newmtl FaceTexture" << std::endl;
mtl_file << "map_Kd " << get_filename(texture_filename) << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion python/generate-python-bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ PYBIND11_MODULE(eos, eos_module)
.def_readwrite("tti", &core::Mesh::tti, "Triangle texture indices");

core_module.def("write_obj", &core::write_obj, "Writes the given Mesh to an obj file.", py::arg("mesh"), py::arg("filename"));
core_module.def("write_textured_obj", &core::write_textured_obj, "Writes the given Mesh to an obj file, including texture coordinates, and an mtl file containing a reference to the isomap. The texture (isomap) has to be saved separately.", py::arg("mesh"), py::arg("filename"));
core_module.def("write_textured_obj", &core::write_textured_obj, "Writes the given Mesh to an obj file, including texture coordinates, and an mtl file containing a reference to the texture map in the form of <filename>.texture.png. That texture .png file has to be saved separately.", py::arg("mesh"), py::arg("filename"));

core_module.def("read_obj", &core::read_obj, "Reads the given Wavefront .obj file into a Mesh.", py::arg("filename"));

Expand Down

0 comments on commit 174a2c2

Please sign in to comment.