基於區域增長的點雲分割

2021-07-30 10:43:37 字數 3442 閱讀 9948

region growing segmentation(基於區域增長的點雲分割)

pcl::regiongrowing (該類在pcl 1.7.0才有的)

pcl::normalestimation 計算法向量

演算法思路:

選擇種子點:在當前點集a中選擇有最小曲率的點加入種子點集

區域增長:尋找種子點的鄰域點,對於位於a中且與種子點的法向量夾角小於閾值的鄰域點,將其加入當前區域中,如果其曲率小於閾值則也加入種子點集

對於每個種子點,重複2,最終輸出一組類,每個類的點都認為是同一平滑表面的一部分。

region_growing_segmentation.cpp

#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 

<

int>);

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);

(indices);

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 "

<

<

::endl;

std::cout 

<<

"first cluster has "

<

0].indices.size () 

<<

" points."

<

std::cout 

<<

"these are the indices of the points of the initial"

<<

std ::endl 

<<

"cloud that belong to the first cluster:"

<

::endl;

int counter 

=0;while (counter 

0].indices.size ())

std ::cout 

<

::endl;

pcl::pointcloud 

::pointxyzrgb

>::ptr colored_cloud 

= reg.getcoloredcloud ();

pcl::visualization

::cloudviewer viewer (

"cluster viewer");

viewer.showcloud(colored_cloud);

while (

!viewer.wasstopped ())

return (

0); }

cmakelists.txt 

cmake_minimum_required(

version

2.8fatal_error)

project(

region_growing_segmentation)

find_package(

pcl1.5required)

include_directories(

$) link_directories(

$) add_definitions(

$) add_executable (

region_growing_segmentation

region_growing_segmentation.cpp)

target_link_libraries (

region_growing_segmentation

$)

PCL點雲庫 區域增長分割

區域生長演算法是利用了法線 曲率和顏色等資訊來判斷點雲是否應該聚成一類,適用於特徵均勻的連通目標。通過設定的約束條件並結合分割資料的融合需求,利用場景中物體的特徵將不同的目標物體從場景中分割出來。pcl中呼叫區域生長分割類pcl regiongrowing,實現區域生長分割演算法,演算法的目標是按照...

區域生長分割點雲

include include include include include include include include include include intmain int argc,char argv pcl search search pointxyz ptr tree boost s...

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

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