[点云分割] Clustering of Pointclouds into Supervoxels

介绍

“Clustering of Pointclouds into Supervoxels” 是一种点云数据聚类的方法,用于将点云数据分割成具有相似特征的超体素(supervoxel)。

超体素是一种在点云数据中表示连续区域的方法,类似于像素在图像中表示连续区域。超体素是点云数据的小块区域,具有相似的几何特征和颜色特征。通过将点云数据聚类成超体素,可以实现对点云数据的语义分割和对象识别。

“Clustering of Pointclouds into Supervoxels” 方法的主要步骤如下:

  1. 首先,对输入的点云数据进行预处理,包括点云滤波、法线估计等操作,以获取点云的几何和颜色特征。

  2. 然后,通过选择一个种子点(seed point)开始,使用一种聚类算法(如欧几里得聚类或基于图的聚类)将点云数据分割成超体素。聚类过程中,会考虑点云的几何和颜色特征,以确保超体素内的点具有相似的特征。

  3. 聚类过程中,可以根据一些准则(如紧密度、颜色一致性等)对超体素进行合并或分割,以进一步优化聚类结果。

  4. 最后,生成的超体素可以用于点云的语义分割、对象识别等应用。可以根据超体素的特征,将点云数据划分为不同的对象或区域。

“Clustering of Pointclouds into Supervoxels” 方法在点云处理和分析中具有广泛的应用,特别是在三维场景理解、目标检测和机器人导航等领域。通过将点云数据聚类为超体素,可以提取出具有语义信息的局部区域,为后续的处理和分析提供更准确和可靠的数据基础。

效果

代码

#include <pcl/console/parse.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/segmentation/supervoxel_clustering.h>//VTK include needed for drawing graph lines
#include <vtkPolyLine.h>// Types
typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloudT;
typedef pcl::PointNormal PointNT;
typedef pcl::PointCloud<PointNT> PointNCloudT;
typedef pcl::PointXYZL PointLT;
typedef pcl::PointCloud<PointLT> PointLCloudT;void addSupervoxelConnectionsToViewer (PointT &supervoxel_center,PointCloudT &adjacent_supervoxel_centers,std::string supervoxel_name,pcl::visualization::PCLVisualizer::Ptr & viewer);int main (int argc, char ** argv)
{if (argc < 2){pcl::console::print_error ("Syntax is: %s <pcd-file> \n ""--NT Dsables the single cloud transform \n""-v <voxel resolution>\n-s <seed resolution>\n""-c <color weight> \n-z <spatial weight> \n""-n <normal_weight>\n", argv[0]);return (1);}PointCloudT::Ptr cloud (new PointCloudT);pcl::console::print_highlight ("Loading point cloud...\n");if (pcl::io::loadPCDFile<PointT> (argv[1], *cloud)){pcl::console::print_error ("Error loading cloud file!\n");return (1);}bool disable_transform = pcl::console::find_switch (argc, argv, "--NT");float voxel_resolution = 0.008f;// 用于体素化点云数据的分辨率bool voxel_res_specified = pcl::console::find_switch (argc, argv, "-v");if (voxel_res_specified)pcl::console::parse (argc, argv, "-v", voxel_resolution);float seed_resolution = 0.1f; // 用于种子点选择的分辨率bool seed_res_specified = pcl::console::find_switch (argc, argv, "-s");if (seed_res_specified)pcl::console::parse (argc, argv, "-s", seed_resolution);float color_importance = 0.2f;if (pcl::console::find_switch (argc, argv, "-c"))pcl::console::parse (argc, argv, "-c", color_importance);float spatial_importance = 0.4f;if (pcl::console::find_switch (argc, argv, "-z"))pcl::console::parse (argc, argv, "-z", spatial_importance);float normal_importance = 1.0f;if (pcl::console::find_switch (argc, argv, "-n"))pcl::console::parse (argc, argv, "-n", normal_importance);//  //// This is how to use supervoxels//  //pcl::SupervoxelClustering<PointT> super (voxel_resolution, seed_resolution);if (disable_transform)super.setUseSingleCameraTransform (false);super.setInputCloud (cloud);super.setColorImportance (color_importance); // 设置颜色重要性super.setSpatialImportance (spatial_importance); // 设置空间重要性super.setNormalImportance (normal_importance); // 设置法线重要性std::map <std::uint32_t, pcl::Supervoxel<PointT>::Ptr > supervoxel_clusters;pcl::console::print_highlight ("Extracting supervoxels!\n");super.extract (supervoxel_clusters);pcl::console::print_info ("Found %d supervoxels\n", supervoxel_clusters.size ());pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));viewer->setBackgroundColor (0, 0, 0);PointCloudT::Ptr voxel_centroid_cloud = super.getVoxelCentroidCloud (); // 获取超体素的体素质心点云viewer->addPointCloud (voxel_centroid_cloud, "voxel centroids");viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,2.0, "voxel centroids");viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.95, "voxel centroids");PointLCloudT::Ptr labeled_voxel_cloud = super.getLabeledVoxelCloud (); // 获取标记过的点云viewer->addPointCloud (labeled_voxel_cloud, "labeled voxels");viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.8, "labeled voxels");PointNCloudT::Ptr sv_normal_cloud = super.makeSupervoxelNormalCloud (supervoxel_clusters); //获取超体素的法线点云//We have this disabled so graph is easy to see, uncomment to see supervoxel normals//viewer->addPointCloudNormals<PointNormal> (sv_normal_cloud,1,0.05f, "supervoxel_normals");pcl::console::print_highlight ("Getting supervoxel adjacency\n");std::multimap<std::uint32_t, std::uint32_t> supervoxel_adjacency;super.getSupervoxelAdjacency (supervoxel_adjacency); // 获取超体素的邻接关系//To make a graph of the supervoxel adjacency, we need to iterate through the supervoxel adjacency multimapor (auto label_itr = supervoxel_adjacency.cbegin (); label_itr != supervoxel_adjacency.cend (); ){//First get the labelstd::uint32_t supervoxel_label = label_itr->first;//Now get the supervoxel corresponding to the labelpcl::Supervoxel<PointT>::Ptr supervoxel = supervoxel_clusters.at (supervoxel_label);//Now we need to iterate through the adjacent supervoxels and make a point cloud of themPointCloudT adjacent_supervoxel_centers;for (auto adjacent_itr = supervoxel_adjacency.equal_range (supervoxel_label).first; adjacent_itr!=supervoxel_adjacency.equal_range (supervoxel_label).second; ++adjacent_itr){pcl::Supervoxel<PointT>::Ptr neighbor_supervoxel = supervoxel_clusters.at (adjacent_itr->second);adjacent_supervoxel_centers.push_back (neighbor_supervoxel->centroid_);}//Now we make a name for this polygonstd::stringstream ss;ss << "supervoxel_" << supervoxel_label;//This function is shown below, but is beyond the scope of this tutorial - basically it just generates a "star" polygon mesh from the points givenaddSupervoxelConnectionsToViewer (supervoxel->centroid_, adjacent_supervoxel_centers, ss.str (), viewer);//Move iterator forward to next labellabel_itr = supervoxel_adjacency.upper_bound (supervoxel_label);}while (!viewer->wasStopped ()){viewer->spinOnce (100);}return (0);}void addSupervoxelConnectionsToViewer (PointT &supervoxel_center,PointCloudT &adjacent_supervoxel_centers,std::string supervoxel_name,pcl::visualization::PCLVisualizer::Ptr & viewer){vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New ();vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New ();vtkSmartPointer<vtkPolyLine> polyLine = vtkSmartPointer<vtkPolyLine>::New ();//Iterate through all adjacent points, and add a center point to adjacent point pairfor (auto adjacent_itr = adjacent_supervoxel_centers.begin (); adjacent_itr != adjacent_supervoxel_centers.end (); ++adjacent_itr){points->InsertNextPoint (supervoxel_center.data);points->InsertNextPoint (adjacent_itr->data);}// Create a polydata to store everything invtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New ();// Add the points to the datasetpolyData->SetPoints (points);polyLine->GetPointIds  ()->SetNumberOfIds(points->GetNumberOfPoints ());for(unsigned int i = 0; i < points->GetNumberOfPoints (); i++)polyLine->GetPointIds ()->SetId (i,i);cells->InsertNextCell (polyLine);// Add the lines to the datasetpolyData->SetLines (cells);viewer->addModelFromPolyData (polyData,supervoxel_name);}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/163810.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C 语言 http通信

1&#xff0c;C语言本身不包含直接支持HTTP协议的功能&#xff0c;但你可以使用第三方库来实现HTTP客户端或服务器。 以下是一些常用的C语言HTTP库&#xff1a; libcurl&#xff1a;一个支持多种协议的开源库&#xff0c;包括HTTP、HTTPS、FTP等。它提供了一组简单的API&…

因果发现31种高效经典方案汇总,附配套算法和代码

因果发现&#xff08;Causal Discovery&#xff09;是一个复杂的过程&#xff0c;其目标是从大量的数据中确定变量之间的因果关系。这个过程通常涉及到的是如何从纷繁复杂的数据中发现其中隐含的因果关系。有时&#xff0c;研究者可以通过随机实验进行干预来发现因果关系&#…

解决PDF预览时,电子签章、日期等不显示问题

文章目录 问题描述问题排查问题解决 问题描述 在预览PDF时&#xff0c;部分签章或控件没有显示。如下图&#xff1a; 正确应该要这样&#xff1a; 问题排查 根据网上搜索&#xff0c;排查&#xff0c;我先看看&#xff0c;pdf.worker.js 里的这三行代码&#xff0c;是否已经注…

JVM 类加载

① 类加载过程 从上面的图片我们可以看出整个 JVM 执行的流程中&#xff0c;和程序员关系最密切的就是类加载的过程了&#xff0c;所以 接下来我们来看下类加载的执行流程。 对于一个类来说&#xff0c;它的生命周期是这样的&#xff1a; 其中前 5 步是固定的顺序并且也是类加载…

Android : Spinner(列表选项框) + BaseAdapter -简单应用

​​容器与适配器&#xff1a;​​​​​ http://t.csdnimg.cn/ZfAJ7 示例图&#xff1a; 实体类 Demo.java package com.example.mygridviewadapter.entity;public class Demo {private String text;private int img;public Demo(String text, int img) {this.text…

虚拟机解决Linux中Uos和Deepin登录密码忘记的问题 标题Linux Uos Deepin

Uos是切换网络模式解决的(之前有绑定过用户) 因为之前用的是桥接模式登录的时候一直无法联网,改为Nat模式后可以和电脑共用一个网络ip,可以重置密码了,以此解决 ps: 特别说明rw single init/bin/bash 方法和systemd.debug-shell1方法已经失效,不要再做无谓的尝试了Deepin23社区…

Vue + Element UI 实现复制当前行数据功能(复制到新增页面组件值不能更新等问题解决)

1、需求 使用Vue Element UI 实现在列表的操作栏新增一个复制按钮&#xff0c;复制当前行的数据可以打开新增弹窗后亦可以跳转到新增页面&#xff0c;本文实现为跳转到新增页面。 2、实现 1&#xff09;列表页 index.vue <el-table> <!-- 其他列 --> <el-t…

JOSEF 漏电继电器 LLJ-100FG φ45 50-500mA 卡轨安装

系列型号&#xff1a; LLJ-10F(S)漏电继电器LLJ-15F(S)漏电继电器LLJ-16F(S)漏电继电器 LLJ-25F(S)漏电继电器LLJ-30F(S)漏电继电器LLJ-32F(S)漏电继电器 LLJ-60F(S)漏电继电器LLJ-63F(S)漏电继电器LLJ-80F(S)漏电继电器 LLJ-100F(S)漏电继电器LLJ-120F(S)漏电继电器LLJ-125F(S…

推荐一个简单的在线压缩PNG和JPG图片大小的网址

问题描述&#xff1a;推荐一个简单的在线压缩PNG和JPG图片大小的网址 解决&#xff1a; https://www.iloveimg.com/zh-cn/compress-image/compress-png

将对象转成URL参数

背景 有的时候前端跳转到其他平台的页面需要携带额外的参数&#xff0c;需要将对象转成用 & 连接的字符串拼接在路径后面。 实现方法

C++中对SQLite进行增删改查

#include <iostream> #include <sqlite3.h>// 创建数据库连接 sqlite3* OpenDatabase(const char* dbFilePath) {sqlite3* db;// 打开数据库if (sqlite3_open(dbFilePath, &db) ! SQLITE_OK) {std::cerr << "Error opening database." <<…

HTTP ERROR 403 No valid crumb was included in the request

1、报错截图&#xff1a; 2、产生原因&#xff1a; 开启了csrf&#xff0c;即跨站请求伪造 3、新版本不支持页面修改&#xff0c;故需要修改jenkins配置文件 3.1 进入编辑配置文件 vim /etc/sysconfig/jenkins 3.2 修改JENKINS_JAVA_OPTIONS&#xff0c;并保存修改 JENKI…

深度学习之四(循环神经网络Recurrent Neural Networks,RNNs)

概念 循环神经网络(Recurrent Neural Networks,RNNs)是一类专门用于处理序列数据的神经网络,它在处理时考虑了序列数据的顺序和上下文信息。RNNs 在自然语言处理、时间序列分析、语音识别等领域得到广泛应用。 1. 基本结构: RNN 的基本结构包含一个或多个循环单元,每个…

Ubuntu 系统上使用 QQ 邮箱的 SMTP 服务器发送邮件,msmtp(已验证)

安装 msmtp sudo apt-get update sudo apt-get install msmtp2 .配置 msmtp nano ~/.msmtprcdefaults auth on tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile ~/.msmtp.logaccount qq host …

Lua脚本解决redis实现的分布式锁多条命令原子性问题

线程1现在持有锁之后&#xff0c;在执行业务逻辑过程中&#xff0c;他正准备删除锁&#xff0c;而且已经走到了条件判断的过程中&#xff0c;比如他已经拿到了当前这把锁确实是属于他自己的&#xff0c;正准备删除锁&#xff0c;但是此时他的锁到期了&#xff0c;那么此时线程2…

Android : ExpandableListView(折叠列表) +BaseExpandableListAdapter-简单应用

示例图&#xff1a; 实体类DemoData.java package com.example.myexpandablelistview.entity;public class DemoData {private String content;private int img;public DemoData(String content, int img) {this.content content;this.img img;}public String getContent()…

STM32——外部中断

文章目录 0.中断关系映射1.使能 IO 口时钟&#xff0c;初始化 IO 口为输入2.设置 IO 口模式&#xff0c;触发条件&#xff0c;开启 SYSCFG 时钟&#xff0c;设置 IO 口与中断线的映射关系。3.配置NVIC优先级管理&#xff0c;并使能中断4.编写中断服务函数。5.编写中断处理回调函…

springboot多数据源集成

springboot多数据源集成 1、添加依赖2、添加配置3、代码使用4、动态切换数据库 1、添加依赖 <!--多数据源--> <dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version…

[个人笔记] Windows的IT运维笔记

IT技术 - 运维篇 第二章 Windows的IT运维笔记 IT技术 - 运维篇系列文章回顾一、Windows10专业版添加gpedit.msc二、海康威视前端页面导出通道名称参考链接 系列文章回顾 第一章 快速下载微软评估版本镜像的方法 一、Windows10专业版添加gpedit.msc 执行以下bat脚本 echo off…

Rust使用iced构建UI时,如何在界面显示中文字符

注&#xff1a;此文适合于对rust有一些了解的朋友 iced是一个跨平台的GUI库&#xff0c;用于为rust语言程序构建UI界面。 iced的基本逻辑是&#xff1a; UI交互产生消息message&#xff0c;message传递给后台的update&#xff0c;在这个函数中编写逻辑&#xff0c;然后通过…