Commit 354deb3e authored by Patrik Huber's avatar Patrik Huber

Renamed get_*_pca_basis() to get_*_pca_basis_at_point()

This makes the intent clearer - it does not return the i-th basis vector (which one could easily assume, if not reading the function parameter name or documentation).
Also added a note expressing this.
It also leaves room for a future function that actually does return the i-th basis.
parent 50c059c3
...@@ -75,7 +75,7 @@ inline std::vector<float> fit_shape_to_landmarks_linear(const morphablemodel::Mo ...@@ -75,7 +75,7 @@ inline std::vector<float> fit_shape_to_landmarks_linear(const morphablemodel::Mo
Mat V_hat_h = Mat::zeros(4 * num_landmarks, num_coeffs_to_fit, CV_32FC1); Mat V_hat_h = Mat::zeros(4 * num_landmarks, num_coeffs_to_fit, CV_32FC1);
int row_index = 0; int row_index = 0;
for (int i = 0; i < num_landmarks; ++i) { for (int i = 0; i < num_landmarks; ++i) {
auto basis_rows_ = morphable_model.get_shape_model().get_rescaled_pca_basis(vertex_ids[i]); // In the paper, the orthonormal basis might be used? I'm not sure, check it. It's even a mess in the paper. PH 26.5.2014: I think the rescaled basis is fine/better. auto basis_rows_ = morphable_model.get_shape_model().get_rescaled_pca_basis_at_point(vertex_ids[i]); // In the paper, the orthonormal basis might be used? I'm not sure, check it. It's even a mess in the paper. PH 26.5.2014: I think the rescaled basis is fine/better.
Mat basis_rows = Mat(basis_rows_.rows(), basis_rows_.cols(), CV_32FC1, basis_rows_.data()); Mat basis_rows = Mat(basis_rows_.rows(), basis_rows_.cols(), CV_32FC1, basis_rows_.data());
//basisRows.copyTo(V_hat_h.rowRange(rowIndex, rowIndex + 3)); //basisRows.copyTo(V_hat_h.rowRange(rowIndex, rowIndex + 3));
basis_rows.colRange(0, num_coeffs_to_fit).copyTo(V_hat_h.rowRange(row_index, row_index + 3)); basis_rows.colRange(0, num_coeffs_to_fit).copyTo(V_hat_h.rowRange(row_index, row_index + 3));
......
...@@ -125,8 +125,7 @@ public: ...@@ -125,8 +125,7 @@ public:
/** /**
* Return the value of the mean at a given vertex index. * Return the value of the mean at a given vertex index.
* *
* Todo: Rename to get_mean? The other getters are overloaded on the vertex index too. * I think we should just return an Eigen::Vector3f - homogenous coords have no place here?
* I also think we should just return an Eigen::Vector3f - homogenous coords have no place here?
* *
* @param[in] vertex_index A vertex index. * @param[in] vertex_index A vertex index.
* @return A homogeneous vector containing the values at the given vertex index. * @return A homogeneous vector containing the values at the given vertex index.
...@@ -209,12 +208,15 @@ public: ...@@ -209,12 +208,15 @@ public:
/** /**
* Returns the PCA basis for a particular vertex, from the rescaled basis. * Returns the PCA basis for a particular vertex, from the rescaled basis.
* *
* Note: The function does not return the i-th basis vector - it returns all basis
* vectors, but only the block that is relevant for the vertex \p vertex_id.
*
* Todo: Can we return a const & view that points into the original data? * Todo: Can we return a const & view that points into the original data?
* *
* @param[in] vertex_id A vertex index. Make sure it is valid. * @param[in] vertex_id A vertex index. Make sure it is valid.
* @return A 1x3? 3x1? matrix that points to the rows in the original basis. * @return A 1x3? 3x1? matrix that points to the rows in the original basis.
*/ */
Eigen::MatrixXf get_rescaled_pca_basis(int vertex_id) const Eigen::MatrixXf get_rescaled_pca_basis_at_point(int vertex_id) const
{ {
vertex_id *= 3; // the basis is stored in the format [x y z x y z ...] vertex_id *= 3; // the basis is stored in the format [x y z x y z ...]
assert(vertex_id < get_data_dimension()); // Make sure the given vertex index isn't larger than the number of model vertices. assert(vertex_id < get_data_dimension()); // Make sure the given vertex index isn't larger than the number of model vertices.
...@@ -240,10 +242,13 @@ public: ...@@ -240,10 +242,13 @@ public:
/** /**
* Returns the PCA basis for a particular vertex, from the orthonormal basis. * Returns the PCA basis for a particular vertex, from the orthonormal basis.
* *
* Note: The function does not return the i-th basis vector - it returns all basis
* vectors, but only the block that is relevant for the vertex \p vertex_id.
*
* @param[in] vertex_id A vertex index. Make sure it is valid. * @param[in] vertex_id A vertex index. Make sure it is valid.
* @return A matrix that points to the rows in the original basis. * @return A matrix that points to the rows in the original basis.
*/ */
Eigen::MatrixXf get_orthonormal_pca_basis(int vertex_id) const Eigen::MatrixXf get_orthonormal_pca_basis_at_point(int vertex_id) const
{ {
vertex_id *= 3; // the basis is stored in the format [x y z x y z ...] vertex_id *= 3; // the basis is stored in the format [x y z x y z ...]
assert(vertex_id < get_data_dimension()); // Make sure the given vertex index isn't larger than the number of model vertices. assert(vertex_id < get_data_dimension()); // Make sure the given vertex index isn't larger than the number of model vertices.
......
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