Skip to content

Commit

Permalink
Merge pull request #2130 from SergioRAgostinho/pca
Browse files Browse the repository at this point in the history
Fix covariance calculation in PCA
  • Loading branch information
taketwo authored Dec 8, 2017
2 parents c57e1db + 1fdd3db commit 3454813
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/include/pcl/common/impl/pca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ pcl::PCA<PointT>::initCompute ()
demeanPointCloud (*input_, *indices_, mean_, cloud_demean);
assert (cloud_demean.cols () == int (indices_->size ()));
// Compute the product cloud_demean * cloud_demean^T
Eigen::Matrix3f alpha = static_cast<Eigen::Matrix3f> (cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ());
const Eigen::Matrix3f alpha = (1.f / (float (indices_->size ()) - 1.f))
* cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ();

// Compute eigen vectors and values
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> evd (alpha);
Expand Down

0 comments on commit 3454813

Please sign in to comment.