gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:03 26 4
gpt4 key购买 nike

我有一个点云

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

我想复制到

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

同时根据使用 ransac 计算的一些异常值进行过滤。

std::vector<int> inliers;

我目前正在这样做

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

问题:

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

有没有人在对 pcl 执行 ransac 后能够找到法线?

最佳答案

我认为这个答案为时已晚,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-estimation-using-integral-images 复制代码

// 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);

关于c++ - 复制 PCL 点云,同时保留组织或 Ransac + 曲面法线计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28462034/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com