[點云分割] 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.pswp.cn/news/163810.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/163810.shtml
英文地址,請注明出處:http://en.pswp.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;然后通過…