最近因為專案,需要計算點雲的法向量,所以在網上看了一些資料,然後知道pcl庫裡面有這些功能,pcl的法向量計算的原理:
pcl裡面計算點雲(自己的理解)
根據頂點取樣最近的區域性點雲(k個),根據自己的點雲擬合出乙個區域性平面,然後計算平面的法向量。就是頂點的向量。
計算可以通過pca那種,可以計算頂點的三個方向的主成分,然後得到最次的主成分對應的法向量,就是平面法向量。
以下是自己使用pcl計算法向量的過程,因為引用都是pcl庫,所以只需要理解這個庫的使用就可以了。
這樣就得到點雲中的法向量。#include
#include
#include
#include
bool
caculatenormals()
pcl::normalestimation cloud_normals;
pcl::pointcloud
::ptr normals
(new pcl::pointcloud);
//在flann中找到kdtree搜尋機制
pcl::search::kdtree
::ptr tree
(new pcl::search::kdtree()
);//為kdtree增加搜尋的點雲
tree-
>
setinputcloud
(cloud)
; cloud_normals.
setinputcloud
(cloud)
; cloud_normals.
setsearchmethod
(tree)
; cloud_normals.
setksearch(20
);std::clock_t start_read = std::
clock()
; cloud_normals.
compute
(*normals)
; std::clock_t end_read = std::
clock()
;const
float parsing_time =
static_cast
<
float
>
(double
(end_read - start_read))/
1000.f
; std::cout <<
"\t compute normal time parsing "
<< parsing_time <<
" seconds "
<< std::endl;
std::cout <<
"normal num is: "
<< normals-
>
size()
<< std::endl;
std::cout <<
"end compute the cloud normals."
<< std::endl;
//清空
vertices_normals_.
swap
(std::vector()
);for(
int i =
0; i < normals-
>
size()
;++i)
return
true
;}
PCL中計算點雲的法向量並顯示
參考源 利用的是最小二乘估計的方法計算了點雲的法向量,並且提供了兩種法線的顯示方法,還設定了多個viewport,練習了點雲的顯示 include stdafx.h include include include include include include int main 計算法線 pcl n...
點雲的法向量
1.在這裡採用的是pcl點雲庫。pcl點雲庫可能存在配置問題,用cmake時候預設支援的是32位的處理,所以建議安裝pcl 32位的all in one。這樣不容易產生錯誤。2.下面試cmake的內容。cmake minimum required version 2.6 fatal error pr...
PCL點雲索引
點雲索引其實就是將點雲中不同點加上標籤,方便後面的分類提取。有了點雲的索引值可以方便的對點雲進行不同操作 以下舉例說明 1.儲存一點雲中某些特定的點 pcl pointcloudcloud new pcl pointcloud 輸入點雲 pcl io loadpcdfile pcd cloud pc...