Commit 31862eb0 authored by Patrik Huber's avatar Patrik Huber

snake_cased more variables

parent 46705a36
......@@ -38,7 +38,7 @@
* Forward declaration of an internal function
*/
namespace eos { namespace morphablemodel { namespace detail {
eos::render::Mesh sample_to_mesh(cv::Mat shape, cv::Mat color, std::vector<std::array<int, 3>> tvi, std::vector<std::array<int, 3>> tci, std::vector<cv::Vec2f> textureCoordinates = std::vector<cv::Vec2f>());
eos::render::Mesh sample_to_mesh(cv::Mat shape, cv::Mat color, std::vector<std::array<int, 3>> tvi, std::vector<std::array<int, 3>> tci, std::vector<cv::Vec2f> texture_coordinates = std::vector<cv::Vec2f>());
} } }
namespace eos {
......@@ -116,16 +116,16 @@ public:
* for the shape- and color models are both drawn from a standard
* normal (or with the given standard deviation).
*
* @param[in] shapeSigma The shape model standard deviation.
* @param[in] colorSigma The color model standard deviation.
* @param[in] shape_sigma The shape model standard deviation.
* @param[in] color_sigma The color model standard deviation.
* @return A random sample from the model.
*/
render::Mesh draw_sample(float shapeSigma = 1.0f, float colorSigma = 1.0f)
render::Mesh draw_sample(float shape_sigma = 1.0f, float color_sigma = 1.0f)
{
assert(shape_model.get_data_dimension() == color_model.get_data_dimension()); // The number of vertices (= model.getDataDimension() / 3) has to be equal for both models.
cv::Mat shapeSample = shape_model.draw_sample(shapeSigma);
cv::Mat colorSample = color_model.draw_sample(colorSigma);
cv::Mat shapeSample = shape_model.draw_sample(shape_sigma);
cv::Mat colorSample = color_model.draw_sample(color_sigma);
render::Mesh mesh;
if (has_texture_coordinates()) {
......@@ -148,32 +148,32 @@ public:
* @param[in] colorCoefficients The PCA coefficients used to generate the shape sample.
* @return A model instance with given coefficients.
*/
render::Mesh draw_sample(std::vector<float> shapeCoefficients, std::vector<float> colorCoefficients)
render::Mesh draw_sample(std::vector<float> shape_coefficients, std::vector<float> color_coefficients)
{
assert(shape_model.get_data_dimension() == color_model.get_data_dimension()); // The number of vertices (= model.getDataDimension() / 3) has to be equal for both models.
cv::Mat shapeSample;
cv::Mat colorSample;
cv::Mat shape_sample;
cv::Mat color_sample;
if (shapeCoefficients.empty()) {
shapeSample = shape_model.get_mean();
if (shape_coefficients.empty()) {
shape_sample = shape_model.get_mean();
}
else {
shapeSample = shape_model.draw_sample(shapeCoefficients);
shape_sample = shape_model.draw_sample(shape_coefficients);
}
if (colorCoefficients.empty()) {
colorSample = color_model.get_mean();
if (color_coefficients.empty()) {
color_sample = color_model.get_mean();
}
else {
colorSample = color_model.draw_sample(colorCoefficients);
color_sample = color_model.draw_sample(color_coefficients);
}
render::Mesh mesh;
if (has_texture_coordinates()) {
mesh = detail::sample_to_mesh(shapeSample, colorSample, shape_model.get_triangle_list(), color_model.get_triangle_list(), texture_coordinates);
mesh = detail::sample_to_mesh(shape_sample, color_sample, shape_model.get_triangle_list(), color_model.get_triangle_list(), texture_coordinates);
}
else {
mesh = detail::sample_to_mesh(shapeSample, colorSample, shape_model.get_triangle_list(), color_model.get_triangle_list());
mesh = detail::sample_to_mesh(shape_sample, color_sample, shape_model.get_triangle_list(), color_model.get_triangle_list());
}
return mesh;
};
......@@ -248,21 +248,21 @@ void save_model(MorphableModel model, std::string filename)
* @param[in] color PCA color model instance.
* @param[in] tvi Triangle vertex indices.
* @param[in] tci Triangle color indices (usually identical to the vertex indices).
* @param[in] textureCoordinates Optional texture coordinates for each vertex.
* @param[in] texture_coordinates Optional texture coordinates for each vertex.
* @return A mesh created from given parameters.
*/
eos::render::Mesh sample_to_mesh(cv::Mat shape, cv::Mat color, std::vector<std::array<int, 3>> tvi, std::vector<std::array<int, 3>> tci, std::vector<cv::Vec2f> textureCoordinates /* = std::vector<cv::Vec2f>() */)
eos::render::Mesh sample_to_mesh(cv::Mat shape, cv::Mat color, std::vector<std::array<int, 3>> tvi, std::vector<std::array<int, 3>> tci, std::vector<cv::Vec2f> texture_coordinates /* = std::vector<cv::Vec2f>() */)
{
assert(shape.rows == color.rows); // The number of vertices (= model.getDataDimension() / 3) has to be equal for both models.
auto numVertices = shape.rows / 3;
auto num_vertices = shape.rows / 3;
eos::render::Mesh mesh;
// Construct the mesh vertices and vertex color information:
mesh.vertices.resize(numVertices);
mesh.colors.resize(numVertices);
for (auto i = 0; i < numVertices; ++i) {
mesh.vertices.resize(num_vertices);
mesh.colors.resize(num_vertices);
for (auto i = 0; i < num_vertices; ++i) {
mesh.vertices[i] = cv::Vec4f(shape.at<float>(i * 3 + 0), shape.at<float>(i * 3 + 1), shape.at<float>(i * 3 + 2), 1.0f);
mesh.colors[i] = cv::Vec3f(color.at<float>(i * 3 + 0), color.at<float>(i * 3 + 1), color.at<float>(i * 3 + 2)); // order in hdf5: RGB. Order in OCV: BGR. But order in vertex.color: RGB
}
......@@ -272,10 +272,10 @@ eos::render::Mesh sample_to_mesh(cv::Mat shape, cv::Mat color, std::vector<std::
mesh.tci = tci;
// Texture coordinates, if the model has them:
if (!textureCoordinates.empty()) {
mesh.texcoords.resize(numVertices);
for (auto i = 0; i < numVertices; ++i) {
mesh.texcoords[i] = textureCoordinates[i];
if (!texture_coordinates.empty()) {
mesh.texcoords.resize(num_vertices);
for (auto i = 0; i < num_vertices; ++i) {
mesh.texcoords[i] = texture_coordinates[i];
}
}
......
......@@ -279,25 +279,25 @@ private:
* eigenvector by the square root of its corresponding
* eigenvalue.
*
* @param[in] unnormalisedBasis An unnormalised PCA basis matrix.
* @param[in] unnormalised_basis An unnormalised PCA basis matrix.
* @param[in] eigenvalues A row or column vector of eigenvalues.
* @return The normalised PCA basis matrix.
*/
inline cv::Mat normalise_pca_basis(cv::Mat unnormalisedBasis, cv::Mat eigenvalues)
inline cv::Mat normalise_pca_basis(cv::Mat unnormalised_basis, cv::Mat eigenvalues)
{
using cv::Mat;
Mat normalisedPcaBasis(unnormalisedBasis.size(), unnormalisedBasis.type()); // empty matrix with the same dimensions
Mat sqrtOfEigenvalues = eigenvalues.clone();
Mat normalised_basis(unnormalised_basis.size(), unnormalised_basis.type()); // empty matrix with the same dimensions
Mat sqrt_of_eigenvalues = eigenvalues.clone();
for (int i = 0; i < eigenvalues.rows; ++i) {
sqrtOfEigenvalues.at<float>(i) = std::sqrt(eigenvalues.at<float>(i));
sqrt_of_eigenvalues.at<float>(i) = std::sqrt(eigenvalues.at<float>(i));
}
// Normalise the basis: We multiply each eigenvector (i.e. each column) with the square root of its corresponding eigenvalue
for (int basis = 0; basis < unnormalisedBasis.cols; ++basis) {
Mat normalisedEigenvector = unnormalisedBasis.col(basis).mul(sqrtOfEigenvalues.at<float>(basis));
normalisedEigenvector.copyTo(normalisedPcaBasis.col(basis));
for (int basis = 0; basis < unnormalised_basis.cols; ++basis) {
Mat normalised_eigenvector = unnormalised_basis.col(basis).mul(sqrt_of_eigenvalues.at<float>(basis));
normalised_eigenvector.copyTo(normalised_basis.col(basis));
}
return normalisedPcaBasis;
return normalised_basis;
};
/**
......@@ -306,25 +306,25 @@ inline cv::Mat normalise_pca_basis(cv::Mat unnormalisedBasis, cv::Mat eigenvalue
* eigenvector by 1 over the square root of its corresponding
* eigenvalue.
*
* @param[in] normalisedBasis A normalised PCA basis matrix.
* @param[in] normalised_basis A normalised PCA basis matrix.
* @param[in] eigenvalues A row or column vector of eigenvalues.
* @return The unnormalised PCA basis matrix.
*/
inline cv::Mat unnormalise_pca_basis(cv::Mat normalisedBasis, cv::Mat eigenvalues)
inline cv::Mat unnormalise_pca_basis(cv::Mat normalised_basis, cv::Mat eigenvalues)
{
using cv::Mat;
Mat unnormalisedBasis(normalisedBasis.size(), normalisedBasis.type()); // empty matrix with the same dimensions
Mat oneOverSqrtOfEigenvalues = eigenvalues.clone();
Mat unnormalised_basis(normalised_basis.size(), normalised_basis.type()); // empty matrix with the same dimensions
Mat one_over_sqrt_of_eigenvalues = eigenvalues.clone();
for (int i = 0; i < eigenvalues.rows; ++i) {
oneOverSqrtOfEigenvalues.at<float>(i) = 1.0f / std::sqrt(eigenvalues.at<float>(i));
one_over_sqrt_of_eigenvalues.at<float>(i) = 1.0f / std::sqrt(eigenvalues.at<float>(i));
}
// De-normalise the basis: We multiply each eigenvector (i.e. each column) with 1 over the square root of its corresponding eigenvalue
for (int basis = 0; basis < normalisedBasis.cols; ++basis) {
Mat unnormalisedEigenvector = normalisedBasis.col(basis).mul(oneOverSqrtOfEigenvalues.at<float>(basis));
unnormalisedEigenvector.copyTo(unnormalisedBasis.col(basis));
for (int basis = 0; basis < normalised_basis.cols; ++basis) {
Mat unnormalised_eigenvector = normalised_basis.col(basis).mul(one_over_sqrt_of_eigenvalues.at<float>(basis));
unnormalised_eigenvector.copyTo(unnormalised_basis.col(basis));
}
return unnormalisedBasis;
return unnormalised_basis;
};
} /* namespace morphablemodel */
......
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