Commit fe16396d authored by Patrik Huber's avatar Patrik Huber

Renamed writeObj

parent 145c8fdf
...@@ -188,7 +188,7 @@ int main(int argc, char *argv[]) ...@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
// Obtain the full mesh and draw it using the estimated camera: // Obtain the full mesh and draw it using the estimated camera:
render::Mesh mesh = morphableModel.drawSample(fittedCoeffs, vector<float>()); render::Mesh mesh = morphableModel.drawSample(fittedCoeffs, vector<float>());
render::writeObj(mesh, "out.obj"); // save the mesh as obj render::write_obj(mesh, "out.obj"); // save the mesh as obj
// Draw the projected points again, this time using the fitted model shape: // Draw the projected points again, this time using the fitted model shape:
for (auto&& idx : vertexIndices) { for (auto&& idx : vertexIndices) {
...@@ -199,7 +199,7 @@ int main(int argc, char *argv[]) ...@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
// Save the output image: // Save the output image:
cv::imwrite("out.png", outimg); cv::imwrite("out.png", outimg);
std::cout << "Finished fitting and wrote result to out.png." << std::endl; cout << "Finished fitting and wrote result to out.png." << endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
* @param[in] mesh The mesh to save as obj. * @param[in] mesh The mesh to save as obj.
* @param[in] filename Output filename. * @param[in] filename Output filename.
*/ */
void writeObj(Mesh mesh, std::string filename); void write_obj(Mesh mesh, std::string filename);
} /* namespace render */ } /* namespace render */
} /* namespace eos */ } /* namespace eos */
......
...@@ -25,19 +25,19 @@ ...@@ -25,19 +25,19 @@
namespace eos { namespace eos {
namespace render { namespace render {
void writeObj(Mesh mesh, std::string filename) void write_obj(Mesh mesh, std::string filename)
{ {
std::ofstream objFile(filename);
assert(mesh.vertices.size() == mesh.colors.size()); assert(mesh.vertices.size() == mesh.colors.size());
std::ofstream obj_file(filename);
for (std::size_t i = 0; i < mesh.vertices.size(); ++i) { for (std::size_t i = 0; i < mesh.vertices.size(); ++i) {
objFile << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << " " << mesh.colors[i][0] << " " << mesh.colors[i][1] << " " << mesh.colors[i][2] << " " << std::endl; obj_file << "v " << mesh.vertices[i][0] << " " << mesh.vertices[i][1] << " " << mesh.vertices[i][2] << " " << mesh.colors[i][0] << " " << mesh.colors[i][1] << " " << mesh.colors[i][2] << " " << std::endl;
} }
for (auto&& v : mesh.tvi) { for (auto&& v : mesh.tvi) {
// Add one because obj starts counting triangle indices at 1 // Add one because obj starts counting triangle indices at 1
objFile << "f " << v[0] + 1 << " " << v[1] + 1 << " " << v[2] + 1 << std::endl; obj_file << "f " << v[0] + 1 << " " << v[1] + 1 << " " << v[2] + 1 << std::endl;
} }
return; return;
......
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