Commit d5fcd7ae authored by Patrik Huber's avatar Patrik Huber

Move incrementing the vertex indices for Matlab into the converter function

parent 7ecd2e60
......@@ -92,14 +92,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
fitting::RenderingParameters rendering_parameters;
std::tie(mesh, rendering_parameters) = fitting::fit_shape_and_pose(morphable_model, blendshapes, landmarks, landmark_mapper, image_width, image_height, edge_topology, contour_landmarks, model_contour, num_iterations, num_shape_coefficients_to_fit, lambda);
// C++ counts the vertex indices starting at zero, Matlab starts counting
// at one - therefore, add +1 to all triangle indices:
for (auto&& t : mesh.tvi) {
for (auto&& idx : t) {
idx += 1;
}
}
// Return the mesh and the rendering_parameters:
OutputArguments output(nlhs, plhs, 2);
output.set(0, mesh);
......
......@@ -199,14 +199,30 @@ mxArray* MxArray::from(const std::vector<std::array<int, 3>>& data)
* @return An mxArray containing a Matlab struct with all vertex, colour, texcoords and triangle data.
*/
template<>
mxArray* MxArray::from(const eos::core::Mesh& mesh) {
mxArray* MxArray::from(const eos::core::Mesh& mesh)
{
// C++ counts the vertex indices starting at zero, Matlab starts counting
// at one - therefore, add +1 to all triangle indices:
auto tvi_1based = mesh.tvi;
for (auto&& t : tvi_1based) {
for (auto&& idx : t) {
idx += 1;
}
}
// Same for tci:
auto tci_1based = mesh.tci;
for (auto&& t : tci_1based) {
for (auto&& idx : t) {
idx += 1;
}
}
MxArray out_array(MxArray::Struct());
out_array.set("vertices", mesh.vertices);
out_array.set("colors", mesh.colors);
out_array.set("texcoords", mesh.texcoords);
out_array.set("tvi", mesh.tvi);
out_array.set("tci", mesh.tci);
out_array.set("tvi", tvi_1based);
out_array.set("tci", tci_1based);
return out_array.release();
};
......
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