复制PCL点云,同时保留组织或Ransac+曲面法线计算



我有一个点云

pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);

我想复制到

pcl::PointCloud<pcl::PointXYZRGBA>::Ptr finalcloud (new pcl::PointCloud<pcl::PointXYZRGBA>);

同时基于使用transa计算的一些inlier进行过滤。

std::vector<int> inliers;

我目前作为做这件事

pcl::copyPointCloud<pcl::PointXYZRGBA>(*cloud, inliers, *finalcloud);

问题

由于我想找到这个云的法线,我需要维护组织。copyPointCloud函数使新的点云高度=1(参见PCL io.hpp的第188行)。

有人能在对pcl执行事务处理后找到法线吗?

我认为这个答案太晚了,API可能会从2015年开始改变。但我会回答的。

法线估计将同时适用于有组织云和无组织云。

无组织云

我正在从复制代码http://pointclouds.org/documentation/tutorials/normal_estimation.php在该代码中,KdTree将用于估计邻居。

#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  ... read, pass in or create a point cloud ...
  // Create the normal estimation class, and pass the input dataset to it
  pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
  ne.setInputCloud (cloud);
  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
  ne.setSearchMethod (tree);
  // Output datasets
  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
  // Use all neighbors in a sphere of radius 3cm
  ne.setRadiusSearch (0.03);
  // Compute the features
  ne.compute (*cloud_normals);
  // cloud_normals->points.size () should have the same size as the input cloud->points.size ()*
}

有组织的云

我正在从复制代码http://www.pointclouds.org/documentation/tutorials/normal_estimation_using_integral_images.php#normal-利用积分图像进行估计

// load point cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile ("table_scene_mug_stereo_textured.pcd", *cloud);
// estimate normals
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
pcl::IntegralImageNormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
ne.setNormalEstimationMethod (ne.AVERAGE_3D_GRADIENT);
ne.setMaxDepthChangeFactor(0.02f);
ne.setNormalSmoothingSize(10.0f);
ne.setInputCloud(cloud);
ne.compute(*normals);

最新更新