平面模型分割

本教程介绍了如何使用PCL库对点云数据进行平面分割。通过创建SACSegmentation对象并设置RANSAC方法,可以确定点云中支持平面模型的点,并输出平面参数。教程中还展示了如何处理异常值并显示内点集。
摘要由CSDN通过智能技术生成

在本教程中,将学习如何对一组点进行简单的平面分割,即找到点云中支持平面模型的所有点。

创建planar_segmentation.cpp文件

源码:

 1#include <iostream>
 2#include <pcl/ModelCoefficients.h>
 3#include <pcl/io/pcd_io.h>
 4#include <pcl/point_types.h>
 5#include <pcl/sample_consensus/method_types.h>
 6#include <pcl/sample_consensus/model_types.h>
 7#include <pcl/segmentation/sac_segmentation.h>
 8
 9int
10 main ()
11{
12  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
13
14  // Fill in the cloud data
15  cloud->width  = 15;
16  cloud->height = 1;
17  cloud->points.resize (cloud->width * cloud->height);
18
19  // Generate the data
20  for (auto& point: *cloud)
21  {
22    point.x = 1024 * rand () / (RAND_MAX + 1.0f);
23    point.y = 1024 * rand () / (RAND_MAX + 1.0f);
24    point.z = 1.0;
25  }
26
27  // Set a few outliers
28  (*cloud)[0].z = 2.0;
29  (*cloud)[3].z = -2.0;
30  (*cloud)[6].z = 4.0;
31
32  std::cerr << "Point cloud data: " << cloud->size () << " points" << std::endl;
33  for (const auto& point: *cloud)
34    std::cerr << "    " << point.x << " "
35                        << point.y << " "
36                        << point.z << std::endl;
37
38  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
39  pcl::PointIndices::Pt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

目标成为slam大神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值