Commit 9b17ea9b authored by Patrik Huber's avatar Patrik Huber

Added to_matrix() to blendshapes

parent c2b4ba1c
......@@ -29,6 +29,8 @@
#include "opencv2/core/core.hpp"
#include <string>
#include <vector>
#include <cassert>
#include <fstream>
namespace eos {
......@@ -81,6 +83,24 @@ std::vector<Blendshape> load_blendshapes(std::string filename)
return blendshapes;
};
/**
* @brief Copies the blendshapes into a matrix, with each column being a blendshape.
*
* @param[in] blendshapes Vector of blendshapes.
* @return The resulting matrix.
*/
cv::Mat to_matrix(const std::vector<Blendshape>& blendshapes)
{
// assert: all blendshapes have to have the same number of rows, and one col
assert(blendshapes.size() > 0);
cv::Mat blendshapes_as_basis(blendshapes[0].deformation.rows, blendshapes.size(), CV_32FC1);
for (int i = 0; i < blendshapes.size(); ++i)
{
blendshapes[i].deformation.copyTo(blendshapes_as_basis.col(i));
}
return blendshapes_as_basis;
};
} /* namespace morphablemodel */
} /* namespace eos */
......
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