首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >点云库(PCL):仅提取曲面的顶点

点云库(PCL):仅提取曲面的顶点
EN

Stack Overflow用户
提问于 2021-05-10 20:58:25
回答 3查看 268关注 0票数 1

我需要一些使用PCL库的帮助。我只是点云的初学者。

我有一个很大的点云,我可以从中提取平面。我最终得到了6个单独存储在不同点云中的曲面。我使用XYZRGB点。然而,每个点云最终都会有几千个点。The surfaces ploted using matplotlib

代码语言:javascript
复制
pcl::PointCloud<pcl::PointXYZRGB>::Ptr Surfacei

Size of Surface1 before : 216224 
Size of Surface2 before : 5407 
Size of Surface3 before : 4168 
Size of Surface4 before : 7298 
Size of Surface5 before : 5621 
Size of Surface6 before : 30474 

然而,我需要减少这个点数,因为它对于我需要的东西来说真的很大。通过这样做,我最终使用了pcl::ConvexHull类:

代码语言:javascript
复制
pcl::ConvexHull<pcl::PointXYZRGB> chull;
chull.setInputCloud(Surfacei);
chull.reconstruct(*Surfacei);

点数明显减少:

代码语言:javascript
复制
Size of Surface1 before : 30 
Size of Surface2 before : 21 
Size of Surface3 before : 127 
Size of Surface4 before : 21 
Size of Surface5 before : 25 
Size of Surface6 before : 17 

The news plot looks like this

因为平面是四边形的,所以我只想提取每个平面顶点的坐标,但我找不到任何东西来帮助我这样做。

有人能帮我拿一下这个吗?

EN

回答 3

Stack Overflow用户

发布于 2021-11-30 05:42:16

我认为使用凸包可以帮助您找到覆盖所有点的最小多边形以及相应的多边形边和顶点。

票数 1
EN

Stack Overflow用户

发布于 2021-05-12 01:58:54

在下面的代码中,我要从点云( cloud )到新的点云(cloud_segmented)提取主平面(最大的大致平面)。我可以保证这是可行的。从这个平面上,您可以通过查找极端坐标轻松地提取顶点。然而,您需要弄清楚的是,如何扩展它以获得多个平面。

此外,在您的特定示例中,您是否可视化了提取的曲面?如果你确实得到了一个点的表面,你可以很容易地提取极值点来获得你的顶点。

代码语言:javascript
复制
    pcl::PointCloud<pcl::PointXYZ> cloud;
    pcl::PointCloud<pcl::PointXYZ> cloud_segmented;

    pcl::ModelCoefficients coefficients;
    pcl::PointIndices::Ptr inliers(new pcl::PointIndices());

    pcl::SACSegmentation<pcl::PointXYZ> segmentation;
    segmentation.setModelType(pcl::SACMODEL_PLANE);
    segmentation.setMethodType(pcl::SAC_RANSAC);
    segmentation.setMaxIterations(1000);
    segmentation.setDistanceThreshold(0.01);
    segmentation.setInputCloud(cloud.makeShared());
    segmentation.segment(*inliers, coefficients);

    pcl_msgs::ModelCoefficients ros_coefficients;
    pcl_conversions::fromPCL(coefficients, ros_coefficients);
    ros_coefficients.header.stamp = input.header.stamp;
    coef_pub.publish(ros_coefficients);

    pcl_msgs::PointIndices ros_inliers;
    pcl_conversions::fromPCL(*inliers, ros_inliers);
    ros_inliers.header.stamp = input.header.stamp;
    ind_pub.publish(ros_inliers);

    pcl::ExtractIndices<pcl::PointXYZ> extract;
    extract.setInputCloud(cloud.makeShared());
    extract.setIndices(inliers);
    extract.setNegative(false);
    extract.filter(cloud_segmented);
票数 0
EN

Stack Overflow用户

发布于 2021-05-13 04:19:50

如果要减少点云中的点数过滤器,可以使用VoxelGrid

Official Tutorial: Downsampling a PointCloud using a VoxelGrid filter

使用示例(来自上面的教程):

代码语言:javascript
复制
  pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
  sor.setInputCloud (cloud);
  sor.setLeafSize (0.01f, 0.01f, 0.01f);
  sor.filter (*cloud_filtered);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67470862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档