当前位置: 首页 > news >正文

【PCL】(二十七)基于法线差的点云分割

(二十七)基于法线差的点云分割


图片来源

提出这个方法的论文:Difference of Normals as a Multi-Scale Operator in Unorganized Point Clouds

算法流程:

  • 在大尺度的范围内(半径 r 1 r_1 r1)估计每个点的法线;

  • 在晓尺度的范围(半径 r 2 r_2 r2)估计每个点的法线;

  • 计算法线差(Difference of Normals (DoN));

  • 根据设定的法线差阈值过滤点;

  • 对剩余的点进行欧几里得分割。

don_segmentation.cpp

/*** @file don_segmentation.cpp* Difference of Normals Example for PCL Segmentation Tutorials.** @author Yani Ioannou* @date 2012-09-24*/
#include <string>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/search/organized.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/segmentation/extract_clusters.h>
#include <pcl/features/don.h>using namespace pcl;int main (int argc, char *argv[])
{///The smallest scale to use in the DoN filter.double scale1;///The largest scale to use in the DoN filter.double scale2;///The minimum DoN magnitude to threshold bydouble threshold;///segment scene into clusters with given distance tolerance using euclidean clusteringdouble segradius;if (argc < 6){std::cerr << "usage: " << argv[0] << " inputfile smallscale largescale threshold segradius" << std::endl;exit (EXIT_FAILURE);}/// the file to read from.std::string infile = argv[1];/// small scalestd::istringstream (argv[2]) >> scale1;/// large scalestd::istringstream (argv[3]) >> scale2;std::istringstream (argv[4]) >> threshold;   // threshold for DoN magnitudestd::istringstream (argv[5]) >> segradius;   // threshold for radius segmentation// Load cloud in blob formatpcl::PCLPointCloud2 blob;pcl::io::loadPCDFile (infile.c_str (), blob);pcl::PointCloud<PointXYZRGB>::Ptr cloud (new pcl::PointCloud<PointXYZRGB>);pcl::fromPCLPointCloud2 (blob, *cloud);// OrganizedNeighbor适用于有组织的数据。KDTree适用于无组织的数据pcl::search::Search<PointXYZRGB>::Ptr tree;if (cloud->isOrganized ()){tree.reset (new pcl::search::OrganizedNeighbor<PointXYZRGB> ());}else{tree.reset (new pcl::search::KdTree<PointXYZRGB> (false));}// Set the input pointcloud for the search treetree->setInputCloud (cloud);if (scale1 >= scale2){std::cerr << "Error: Large scale must be > small scale!" << std::endl;exit (EXIT_FAILURE);}// 计算每个点小尺度和大尺度的法线// 通过OpenMP多线程,使用处理器中的多个内核来计算法线pcl::NormalEstimationOMP<PointXYZRGB, PointNormal> ne;  // PointNormal-float x,y,z,normal[3], curvaturene.setInputCloud (cloud);ne.setSearchMethod (tree);// 设置一个在所有法线计算中使用的视点,确保了在不同尺度上估计的法线的基本方向一致。ne.setViewPoint (std::numeric_limits<float>::max (), std::numeric_limits<float>::max (), std::numeric_limits<float>::max ());// calculate normals with the small scalestd::cout << "Calculating normals for scale..." << scale1 << std::endl;pcl::PointCloud<PointNormal>::Ptr normals_small_scale (new pcl::PointCloud<PointNormal>);ne.setRadiusSearch (scale1);ne.compute (*normals_small_scale);// calculate normals with the large scalestd::cout << "Calculating normals for scale..." << scale2 << std::endl;pcl::PointCloud<PointNormal>::Ptr normals_large_scale (new pcl::PointCloud<PointNormal>);ne.setRadiusSearch (scale2);ne.compute (*normals_large_scale);// Create output cloud for DoN resultsPointCloud<PointNormal>::Ptr doncloud (new pcl::PointCloud<PointNormal>);copyPointCloud (*cloud, *doncloud);std::cout << "Calculating DoN... " << std::endl;// DoN 估计模板的3个参数<第一个对应于输入点云类型,第二个对应于为点云估计的法线类型.第三个对应于输出类型pcl::DifferenceOfNormalsEstimation<PointXYZRGB, PointNormal, PointNormal> don;don.setInputCloud (cloud);don.setNormalScaleLarge (normals_large_scale);don.setNormalScaleSmall (normals_small_scale);if (!don.initCompute ()){std::cerr << "Error: Could not initialize DoN feature operator" << std::endl;exit (EXIT_FAILURE);}// Compute DoNdon.computeFeature (*doncloud);// Save DoN featurespcl::PCDWriter writer;writer.write<pcl::PointNormal> ("don.pcd", *doncloud, false); std::cout << "Filtering out DoN mag <= " << threshold << "..." << std::endl;// 设定滤波条件,根据点的法线差矢量过滤点 pcl::ConditionOr<PointNormal>::Ptr range_cond (new pcl::ConditionOr<PointNormal> ());// "curvature" :过滤DoN的l2范数小于threshold的点range_cond->addComparison (pcl::FieldComparison<PointNormal>::ConstPtr (new pcl::FieldComparison<PointNormal> ("curvature", pcl::ComparisonOps::GT, threshold)));// 创建条件滤波器pcl::ConditionalRemoval<PointNormal> condrem;condrem.setCondition (range_cond);condrem.setInputCloud (doncloud);pcl::PointCloud<PointNormal>::Ptr doncloud_filtered (new pcl::PointCloud<PointNormal>);// Apply filtercondrem.filter (*doncloud_filtered);doncloud = doncloud_filtered;// Save filtered outputstd::cout << "Filtered Pointcloud: " << doncloud->size () << " data points." << std::endl;writer.write<pcl::PointNormal> ("don_filtered.pcd", *doncloud, false); // 欧几里得聚类分割std::cout << "Clustering using EuclideanClusterExtraction with tolerance <= " << segradius << "..." << std::endl;pcl::search::KdTree<PointNormal>::Ptr segtree (new pcl::search::KdTree<PointNormal>);segtree->setInputCloud (doncloud);std::vector<pcl::PointIndices> cluster_indices;pcl::EuclideanClusterExtraction<PointNormal> ec;ec.setClusterTolerance (segradius);ec.setMinClusterSize (50);ec.setMaxClusterSize (100000);ec.setSearchMethod (segtree);ec.setInputCloud (doncloud);ec.extract (cluster_indices);int j = 0;for (const auto& cluster : cluster_indices){pcl::PointCloud<PointNormal>::Ptr cloud_cluster_don (new pcl::PointCloud<PointNormal>);for (const auto& idx : cluster.indices){cloud_cluster_don->points.push_back ((*doncloud)[idx]);}cloud_cluster_don->width = cloud_cluster_don->size ();cloud_cluster_don->height = 1;cloud_cluster_don->is_dense = true;//Save clusterstd::cout << "PointCloud representing the Cluster: " << cloud_cluster_don->size () << " data points." << std::endl;std::stringstream ss;ss << "don_cluster_" << j << ".pcd";writer.write<pcl::PointNormal> (ss.str (), *cloud_cluster_don, false);++j;}
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(don_segmentation)find_package(PCL 1.7 REQUIRED)include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})add_executable (don_segmentation don_segmentation.cpp)
target_link_libraries (don_segmentation ${PCL_LIBRARIES})

数据样例

编译并运行:

$ ./don_segmentation <inputfile> <smallscale> <largescale> <threshold> <segradius>
$./don_segmentation 003000.pcd 0.4 2 0.2 0.5

DoN:
在这里插入图片描述

根据DoN滤除点:

聚类:

相关文章:

【PCL】(二十七)基于法线差的点云分割

&#xff08;二十七&#xff09;基于法线差的点云分割 图片来源 提出这个方法的论文&#xff1a;Difference of Normals as a Multi-Scale Operator in Unorganized Point Clouds 算法流程&#xff1a; 在大尺度的范围内&#xff08;半径 r 1 r_1 r1​&#xff09;估计每个点…...

智慧公厕系统的组成部分有什么?

智慧公厕系统是现代城市管理中一项重要的创新&#xff0c;利用物联网、互联网、大数据、云计算、自动化控制等先进的技术手段&#xff0c;提供高效便捷的公厕服务。从信息系统的角度来看&#xff0c;智慧公厕系统主要由硬件、软件和网络组成&#xff0c;硬件、软件和网络三大部…...

[数据集][目标检测]芒果叶病害数据集VOC+YOLO格式4000张5类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;4000 标注数量(xml文件个数)&#xff1a;4000 标注数量(txt文件个数)&#xff1a;4000 标注…...

Linux: 预备

计算机结构基础 操作系统: 内核 (管理软硬件) shell(给用户使用操作系统的方式) 操作系统的目标 对硬件抽象 原因:操作系统是对软硬件资源管理的应用软件抽象:内存管理, 进程管理, 文件管理, 驱动管理软件:驱动程序(给软件提供访问硬件的软件)硬件:磁盘(对应文件), 网卡等隔离…...

ChatGPT 升级出现「我们未能验证您的支付方式/we are unable to authenticate」怎么办?

ChatGPT 升级出现「我们未能验证您的支付方式/we are unable to authenticate」怎么办&#xff1f; 在订阅 ChatGPT Plus 时&#xff0c;有时候会出现以下报错 &#xff1a; We are unable to authenticate your payment method. 我们未能验证您的支付方式。 出现 unable to a…...

JavaWeb - 3 - JavaScript(JS)

JavaScript(JS)官方参考文档&#xff1a;JavaScript 教程 JavaScript&#xff08;简称&#xff1a;JS&#xff09;是一门跨平台、面向对象的脚本语言&#xff0c;是用来控制网页行为的&#xff0c;它能使网页可交互&#xff08;脚本语言就不需要编译&#xff0c;直接通过浏览器…...

基于springboot+vue的美食烹饪互动平台

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、阿里云专家博主、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战&#xff0c;欢迎高校老师\讲师\同行交流合作 ​主要内容&#xff1a;毕业设计(Javaweb项目|小程序|Pyt…...

linux中操作服务器常用命令

在Linux中操作服务器时&#xff0c;常用的命令包括&#xff1a; ls&#xff1a;列出目录内容。 cd&#xff1a;切换目录。 pwd&#xff1a;显示当前所在的目录路径。 mkdir&#xff1a;创建一个新的目录。 rmdir&#xff1a;删除一个空的目录。 cp&#xff1a;复制文件或目录。…...

最简k8s部署(AWS Load Balancer Controller使用)

问题 我需要在k8s集群里面部署springboot服务&#xff0c;通过k8s ingress访问集群内部的springboot服务&#xff0c;应该怎么做&#xff1f; 这里假设已经准备好k8s集群&#xff0c;而且也准备好springboot服务的运行镜像了。这里我们将精力放在k8s服务编排上面。 一图胜千言…...

差距拉开了!量化大厂最新业绩排行曝光!

经历了一月份的失落和二月份绝地反攻&#xff0c;量化大厂们的整体业绩备受关注。 而今年2月份的量化战绩&#xff0c;甚为关键&#xff01; 毕竟市场指数“前低后高”&#xff0c;基金经理与投资人开年以来&#xff0c;共同经历了“惊心动魄”的考验。 量化大厂&#xff0c…...

【Web前端】Vue核心基础

文章目录 1. Vue简介2. Vue官网使用指南3. 初识Vue3.1 搭建Vue开发环境3.2 HelloWorld案例3.3 el与data的两种写法3.4 MVVM模型3.5 模板语法 4. 数据绑定4.1 v-bind单向数据绑定4.2 v-model双向数据绑定 5. 事件处理5.1 v-on绑定事件5.2 事件修饰符5.3 键盘事件 6. 计算属性6.1…...

Linux操作系统项目上传Github代码仓库指南

文章目录 1 创建SSH key2.本地git的用户名和邮箱设置3.测试连接4.创建仓库5.终端项目上传 1 创建SSH key 1.登录github官网,点击个人头像,点击Settings,然后点击SSH and GPG keys,再点击New SSH key。 Title 可以随便取&#xff0c;但是 key 需要通过终端生成。 Linux终端执行…...

机器学习--循环神经网路(RNN)2

在这篇文章中&#xff0c;我们介绍一下其他的RNN。 一.深层RNN 循环神经网络的架构是可以任意设计的&#xff0c;之前提到的 RNN 只有一个隐藏层&#xff0c;但 RNN 也可以是深层的。比如把 xt 丢进去之后&#xff0c;它可以通过一个隐藏层&#xff0c;再通过第二个隐藏层&am…...

sheng的学习笔记-AI-多分类学习:ECOC,softmax

目录&#xff1a;sheng的学习笔记-AI目录-CSDN博客 基本术语&#xff1a; 若我们欲预测的是离散值&#xff0c;例如“好瓜”“坏瓜”&#xff0c;此类学习任务称为“分类”(classification)&#xff1b; 若欲预测的是连续值&#xff0c;例如西瓜成熟度0.95、0.37&#xff0c;…...

ChatGPT Plus 支付出现「您的银行卡被拒绝/your card has been declined」怎么办?

ChatGPT Plus 支付出现「您的银行卡被拒绝/your card has been declined」怎么办&#xff1f; 在订阅 ChatGPT Plus 或者 OpenAI API 时&#xff0c;有时候会出现已下报错 &#xff1a; Your card has been declined. 您的银行卡被拒绝 出现这种错误&#xff0c;有以下几个解…...

typescript学习(更新中)

目录 开发环境搭建类型如何声明有哪些类型编译配置文件 开发环境搭建 npm i -g typescripttsc检查是否安装成功 类型如何声明 // 先声明再赋值 let a: number a 1// 直接赋值 let b 1function sum(a: number, b: number): number {return a b } console.log(sum(1, 2))有…...

T2 小美的平衡矩阵(25分) - 美团编程题 题解

考试平台&#xff1a; 牛客网 题目类型&#xff1a; 30道单选题&#xff08;60分&#xff09; 2 道编程题 &#xff08;15分 25分&#xff09; 考试时间&#xff1a; 2024-03-09 &#xff08;两小时&#xff09; 题目描述 小美拿到了一个n*n的矩阵&#xff0c;其中每个元素是…...

13:大数据与Hadoop|分布式文件系统|分布式Hadoop集群

大数据与Hadoop&#xff5c;分布式文件系统&#xff5c;分布式Hadoop集群 Hadoop部署Hadoop HDFS分布式文件系统HDFS部署步骤一&#xff1a;环境准备HDFS配置文件 查官方手册配置Hadoop集群 日志与排错 mapreduce 分布式离线计算框架YARN集群资源管理系统步骤一&#xff1a;安装…...

前端知识点、技巧、webpack、性能优化(持续更新~)

1、 请求太多 页面加载慢 &#xff08;webpack性能优化&#xff09; 可以把 图片转换成 base64 放在src里面 减少服务器请求 但是图片会稍微大一点点 以上的方法不需要一个一个自己转化 可以在webpack 进行 性能优化 &#xff08;官网有详细描述&#xff09;...

红队专题-开源漏扫-巡风xunfeng源码剖析与应用

开源漏扫-巡风xunfeng 介绍主体两部分:网络资产识别引擎,漏洞检测引擎。代码赏析插件编写JSON标示符Python脚本此外系统内嵌了辅助验证功能文件结构功能 模块添加IP三. 进行扫描在这里插入图片描述 ![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/de587a6f6f694…...

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站&#xff0c;会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后&#xff0c;网站没有变化的情况。 不熟悉siteground主机的新手&#xff0c;遇到这个问题&#xff0c;就很抓狂&#xff0c;明明是哪都没操作错误&#x…...

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…...

深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法

深入浅出&#xff1a;JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中&#xff0c;随机数的生成看似简单&#xff0c;却隐藏着许多玄机。无论是生成密码、加密密钥&#xff0c;还是创建安全令牌&#xff0c;随机数的质量直接关系到系统的安全性。Jav…...

基于当前项目通过npm包形式暴露公共组件

1.package.sjon文件配置 其中xh-flowable就是暴露出去的npm包名 2.创建tpyes文件夹&#xff0c;并新增内容 3.创建package文件夹...

什么是EULA和DPA

文章目录 EULA&#xff08;End User License Agreement&#xff09;DPA&#xff08;Data Protection Agreement&#xff09;一、定义与背景二、核心内容三、法律效力与责任四、实际应用与意义 EULA&#xff08;End User License Agreement&#xff09; 定义&#xff1a; EULA即…...

C++.OpenGL (10/64)基础光照(Basic Lighting)

基础光照(Basic Lighting) 冯氏光照模型(Phong Lighting Model) #mermaid-svg-GLdskXwWINxNGHso {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-GLdskXwWINxNGHso .error-icon{fill:#552222;}#mermaid-svg-GLd…...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

EtherNet/IP转DeviceNet协议网关详解

一&#xff0c;设备主要功能 疆鸿智能JH-DVN-EIP本产品是自主研发的一款EtherNet/IP从站功能的通讯网关。该产品主要功能是连接DeviceNet总线和EtherNet/IP网络&#xff0c;本网关连接到EtherNet/IP总线中做为从站使用&#xff0c;连接到DeviceNet总线中做为从站使用。 在自动…...

今日学习:Spring线程池|并发修改异常|链路丢失|登录续期|VIP过期策略|数值类缓存

文章目录 优雅版线程池ThreadPoolTaskExecutor和ThreadPoolTaskExecutor的装饰器并发修改异常并发修改异常简介实现机制设计原因及意义 使用线程池造成的链路丢失问题线程池导致的链路丢失问题发生原因 常见解决方法更好的解决方法设计精妙之处 登录续期登录续期常见实现方式特…...

ABAP设计模式之---“简单设计原则(Simple Design)”

“Simple Design”&#xff08;简单设计&#xff09;是软件开发中的一个重要理念&#xff0c;倡导以最简单的方式实现软件功能&#xff0c;以确保代码清晰易懂、易维护&#xff0c;并在项目需求变化时能够快速适应。 其核心目标是避免复杂和过度设计&#xff0c;遵循“让事情保…...