#include <pcl/point_types.h> #include <pcl/io/ply_io.h> #include <pcl/common/centroid.h> int main() { pcl::PointCloud<pcl::PointXYZ> cloud; pcl::io::loadPLYFile("cube.ply", cloud); // Placeholder for the 3x3 covariance matrix at each surface patch 協方差矩陣 Eigen::Matrix3f covariance_matrix; // 16-bytes aligned placeholder for the XYZ centroid of a surface patch Eigen::Vector4f xyz_centroid; // Estimate the XYZ centroid 質心 pcl::compute3DCentroid(cloud, xyz_centroid); // Compute the 3x3 covariance matrix pcl::computeCovarianceMatrix(cloud, xyz_centroid, covariance_matrix); std::cout << xyz_centroid << std::endl; std::cout << covariance_matrix << std::endl; }