在本教程中,我们将学习如何将点投影到参数化模型上 (例如,平面、球体等)。参数模型通过一组 系数 – 在平面的情况下,通过其方程:ax + by + cz + d = 0。
代码
#include <iostream>
#include <pcl/point_cloud.h> // for PointCloud
#include <pcl/point_types.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>intmain ()
{pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected (new pcl::PointCloud<pcl::PointXYZ>);// Fill in the cloud datacloud->width = 5;cloud->height = 1;cloud->points.resize (cloud->width * cloud->height);for (auto& point: *cloud){point.x = 1024 * rand () / (RAND_MAX + 1.0f);point.y = 1024 * rand () / (RAND_MAX + 1.0f);point.z = 1024 * rand () / (RAND_MAX + 1.0f);}std::cerr