區域生長分割點雲

2021-08-02 21:22:20 字數 2133 閱讀 4039

#include 

#include

#include

#include

#include

#include

#include

#include

#include

#include

intmain(int argc, char** argv)

pcl:

:search

::search

:pointxyz>

::ptr tree = boost:

:shared_ptr:

:search

::search

:pointxyz> >(new pcl:

:search

::kdtree

:pointxyz>);

pcl:

:pointcloud

:normal>

::ptr normals(new pcl:

:pointcloud

:normal>);

pcl:

:normalestimation::pointxyz, pcl:

:normal> normal_estimator;

normal_estimator.setsearchmethod(tree);

normal_estimator.setinputcloud(cloud);

normal_estimator.setksearch(50);

normal_estimator.compute(*normals);

pcl:

:indicesptr indices(new std:

:vector

); // 給定點雲某個字段限定的對點雲進行簡單的過濾

pcl:

:passthrough::pointxyz> pass;

pass.setinputcloud(cloud);

pass.setfilterfieldname("z");

pass.setfilterlimits(0.0, 1.0);

pass.filter(*indices);

// 區域生長點雲分割類

pcl:

:regiongrowing::pointxyz, pcl:

:normal> reg;

// 設定每個類中最少點數

reg.setminclustersize(50);

reg.setmaxclustersize(1000000);

reg.setsearchmethod(tree);

// 設定領域的數量

reg.setnumberofneighbours(30);

reg.setinputcloud(cloud);

reg.setinputnormals(normals);

// 設定平滑閾值大小

reg.setsmoothnessthreshold(3.0 / 180.0 * m_pi);

// 設定曲率閾值

reg.setcurvaturethreshold(1.0);

std:

:vector

:pointindices> clusters;

reg.extract(clusters);

std:

:cout

<< "number of clusters is equal to "

<< clusters.size() << std:

:endl;

std:

:cout

<< "first cluster has "

<< clusters[0].indices.size() << " points."

<< endl;

// 如果點雲成功分割,返回彩色點雲,否則返回為空

pcl:

:pointcloud

:pointxyzrgb>

::ptr colored_cloud = reg.getcoloredcloud();

if (colored_cloud->empty())

else

return (0);

}

區域生長法分割

區域生長法的基本思想就是將具有相似性的畫素集合起來形成乙個區域。具體做法就是,首先選擇乙個種子點,通過比較種子點鄰域的相似性,將鄰域中滿足相似性準則的畫素歸入種子點所在的區域,然後將這新的畫素點定為種子點,重複上述過程,直到沒有滿足相似性準則的新的鄰域畫素點產生為止。通過區域生長,乙個區域就形成了。...

點雲分割入門(2) 基於區域生長的分割演算法

二 基於區域的分割演算法 其中,kd樹用來獲得點雲的拓撲結構,可以得到鄰域資訊。對於kd樹,這就簡單說一下,網上資料很全。點雲空間拓撲關係的建立方式主要有octree 法和 kd tree 法 根據pcl官網例程得到的結果如下圖所示 pcl官網 從圖中可以看出,對於階梯狀的方方正正的建築物,該方法效...

PCL之區域生長分割

首先依據點的曲率值對點進行排序,之所以排序,是因為區域生長演算法是從曲率最小的點開始生長的,這個點就是初始種子點,初始種子點所在的區域即為最平滑的區域,從最平滑的區域開始生長可減少分割片段的總數,提高效率。演算法流程總結 種子周圍的臨近點和種子點雲相比較 法線的方向是否足夠相近 曲率是否足夠小 如果...