日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

PCL基础1:点云数据结构

發(fā)布時間:2023/11/27 生活经验 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PCL基础1:点云数据结构 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.數(shù)據(jù)結構

PCL最基本的數(shù)據(jù)類型就是PointXYZ

這個代表的是一個黑白的點,這個類包含了xyz的坐標,當然也有更高級的PointXYZRGB,這個里面不僅有坐標,還有點的RGB顏色值。

具體如下:

PointXYZI、PointXYZRGBA、PointXYZRGB、PointXY、InterestPoint、Normal、PointNormal、PointXYZRGBNormal、PointXYZINormal、PointXYZLNormal、PointXYZL、PointXYZRGBL、PointXYZHSV、PointWithRange、PointWithViewpoint、MomentInvariants、PrincipalRadiiRSD、Boundary、PrincipalCurvatures、PFHSignature125、FPFHSignature33、VFHSignature308、Narf36、BorderDescription、IntensityGradient、Histogram、PointWithScale、PointSurfel。

具體參見頭文件:pcl/point_types.h

1.PointXYZ

成員變量: float x, y, z;

PointXYZ是使用最常見的一個點數(shù)據(jù)類型,因為它只包含三維xyz坐標信息,這三個浮點數(shù)附加一個浮點數(shù)來滿足存儲對齊,用戶可利用points[i].data[0],或者points[i].x訪問點的x坐標值。

union
{float data[4];struct{float x;float y;float z;};
};

如果我們要定義一連串點云一般用的是PointCloud,這個類里面有個point變量,這個變量實際上用的是STL里面的vector。

PCL的example里通常都是這樣定義點云:

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> );
如果要訪問某一個點,則需要:
cloud->points[i].x
可以看到,points是個vector變量,所以points[i]就是單個的點,這里訪問了他的x的值,同理可以訪問y和z,如果是PointXYZRGB則還有rgb,如果想往cloud這個變量里面添加一個點的信息,則只需要定一個PointXYZ(或PointXYZRGB)的變量,然后通過vector的push_back,加入到points這個變量里面。

 pcl::PointXYZ point;     point.x = 2.0f - y;      point.y = y;      point.z = z;      cloud.points.push_back(point);

如果有兩個坐標相同的點,則顏色信息以最后的一個為準。

如果想要顯示你的點云信息,需要創(chuàng)建一個PCLVisualizer的對象

pcl::visualization::PCLVisualizer::Ptr viewer (new pcl::visualization::PCLVisualizer ("Cloud"));

然后執(zhí)行這個對象的

viewer->addPointCloud (cloud, "cloud");

這樣就可以顯示了,但是很快就消失了,所以感覺并沒有什么用,所以需要加上下面一句,暫停和控制


viewer->spin();
//這樣就是一個完整的顯示了,可以通過鼠標和鍵盤旋轉和放大這個點云來觀察。 

2.PointXYZI

成員變量: float x, y, z, intensity;

PointXYZI是一個簡單的XYZ坐標加intensity的point類型,理想情況下,這四個變量將新建單獨一個結構體,并且滿足存儲對齊,然而,由于point的大部分操作會把data[4]元素設置成0或1(用于變換),不能讓intensity與xyz在同一個結構體中,如果這樣的話其內容將會被覆蓋。例如,兩個點的點積會把他們的第四個元素設置成0,否則該點積沒有意義,等等。因此,對于兼容存儲對齊,用三個額外的浮點數(shù)來填補intensity,這樣在存儲方面效率較低,但是符合存儲對齊要求,運行效率較高。
?

union
{ float data[4];struct{float x;float y;float z;};
};
union
{struct{float intensity;};float data_c[4];
};

3.PointXYZRGBA

成員變量: float x, y, z; uint32_t rgba;

除了rgba信息被包含在一個整型變量中,其它的和PointXYZI類似。

union
{float data[4];struct{float x;float y;float z;};
};
union
{struct{uint32_t rgba;};float data_c[4];
};

.PointXYZRGB

成員變量:float x, y, z, rgb;

除了rgb信息被包含在一個浮點型變量中,其它和PointXYZRGB類似。rgb數(shù)據(jù)被壓縮到一個浮點數(shù)里的原因在于早期PCL是作為ROS項目的一部分來開發(fā)的,那里RGB數(shù)據(jù)是用浮點數(shù)來傳送的,PCL設計者希望所有遺留代碼會重新更改(在PCL 2.x中很可能這樣做),可能取消此數(shù)據(jù)類型。

union
{float data[4];struct{float x;float y;float z;};
};
union
{struct{float rgb;};float data_c[4];
};

5.PointXY

成員變量:float x, y

簡單的二維x-y point結構。

struct
{float x;float y;
};

6.InterestPoint

成員變量:float x, y, z, strength

除了strength表示關鍵點的強度的測量值,其它的和PointXYZI類似。

union
{float data[4];struct{float x;float y;float z;};
};
union
{struct{float strength;};float data_c[4];
};

7 .Normal

成員變量:float normal[3], curvature;
另一個最常用的數(shù)據(jù)類型,Normal結構體表示給定點所在樣本曲面上的法線方向,以及對應曲率的測量值(通過曲面塊特征值之間關系獲得——查看NormalEstimation類API以便獲得更多信息),由于在PCL中對曲面法線的操作很普遍,還是用第四個元素來占位,這樣就兼容SSE和高效計算,例如,用戶訪問法向量的第一個坐標,可以通過points[i].data_n[0]或者points[i].normal[0]或者points[i].normal_x,再一次強調,曲率不能被存儲在同一個結構體中,因為它會被普通的數(shù)據(jù)操作覆蓋掉。

union
{float data_n[4];float normal[3];struct{float normal_x;float normal_y;float normal_z;};
}
union
{struct{float curvature;};float data_c[4];
}

8.PointNormal

成員變量:float x, y, z; float normal[3], curvature;
PointNormal是存儲XYZ數(shù)據(jù)的point結構體,并且包括采樣點對應法線和曲率。

union
{float data[4];struct{float x;float y;float z;};
};
union
{float data_n[4];float normal[3];struct{float normal_x;float normal_y;float normal_z;};
};
union
{struct{float curvature;};float data_c[4];
};

9.PointXYZRGBNormal

成員變量:float x, y, z, rgb, normal[3], curvature;
PointXYZRGBNormal存儲XYZ數(shù)據(jù)和RGB顏色的point結構體,并且包括曲面法線和曲率

union
{float data[4];struct{float x;float y;float z;};
};
union
{float data_n[4];float normal[3];struct{float normal_x;float normal_y;float normal_z;};
}
union
{struct{float rgb;float curvature;};float data_c[4];
};

10.PointXYZINormal

成員變量:float x, y, z, intensity, normal[3], curvature;
PointXYZINormal存儲XYZ數(shù)據(jù)和強度值的point結構體,并且包括曲面法線和曲率。

union
{float data[4];struct{float x;float y;float z;};
};
union
{float data_n[4];float normal[3];struct{float normal_x;float normal_y;float normal_z;};
}
union
{struct{float intensity;float curvature;};float data_c[4];
};

11.PointXYZL

成員變量:float x, y, z, uin32_t label

12.PointXYZRGBL

成員變量: float x, y, z, rgb, uint32_t label

13.PointXYZLNormal

成員變量:float x, y, z, label, normal[3], curvature

14.PointXYZHSV

成員變量: ?float x, y, z, h, s, v

15.PointWithRange

成員變量:float x, y, z(union with float point[4]), range;
PointWithRange除了range包含從所獲得的視點到采樣點的距離測量值之外,其它與PointXYZI類似。

union
{float data[4];struct{float x;float y;float z;};
};
union
{struct{float range;};float data_c[4];
};

16.PointWithViewpoint

成員變量:float x, y, z, vp_x, vp_y, vp_z;
PointWithViewpoint除了vp_x、vp_y和vp_z以三維點表示所獲得的視點之外,其它與PointXYZI一樣。

union
{float data[4];struct{float x;float y;float z;};
};
union
{struct{float vp_x;float vp_y;float vp_z;};float data_c[4];
};

17.MomentInvariants

成員變量:float j1, j2, j3;
MomentInvariants是一個包含采樣曲面上面片的三個不變矩的point類型,描述面片上質量的分布情況。查看MomentInvariantsEstimation以獲得更多信息。

struct
{float j1, j2, j3;
};

18.PrincipalRadiiRSD

成員變量:float r_min, r_max;
PrincipalRadiiRSD是一個包含曲面塊上兩個RSD半徑的point類型,查看RSDEstimation以獲得更多信息。

struct
{float r_min, r_max;
};

19.Boundary

成員變量:uint8_t boundary_point;
Boundary存儲一個點是否位于曲面邊界上的簡單point類型,查看BoundaryEstimation以獲得更多信息。

struct
{uint8_t boundary_point;
};

20.PrincipalCurvatures

成員變量:float principal_curvature[3], pc1, pc2;
PrincipalCurvatures包含給定點主曲率的簡單point類型。查看PrincipalCurvaturesEstimation以獲得更多信息。
?

struct
{union{float principal_curvature[3];struct{float principal_curvature_x;float principal_curvature_y;float principal_curvature_z;};};float pc1;float pc2;
};

21.PFHSignature125

成員變量:float pfh[125];
PFHSignature125包含給定點的PFH(點特征直方圖)的簡單point類型, 查看PFHEstimation以獲得更多信息。

struct
{float histogram[125];
};

22.FPFHSignature33

成員變量:float fpfh[33];
FPFHSignature33包含給定點的FPFH(快速點特征直方圖)的簡單point類型,查看FPFHEstimation以獲得更多信息。

struct
{float histogram[33];
};

23.VFHSignature308

成員變量:float vfh[308];
VFHSignature308包含給定點VFH(視點特征直方圖)的簡單point類型,查看VFHEstimation以獲得更多信息。

struct
{float histogram[308];
};

24.Narf36

成員變量:float x, y, z, roll, pitch, yaw; float descriptor[36];
Narf36包含給定點NARF(歸一化對齊半徑特征)的簡單point類型,查看NARFEstimation以獲得更多信息。

struct
{float x, y, z, roll, pitch, yaw;float descriptor[36];
};

25.BorderDescription

成員變量:int x, y; BorderTraits traits;
BorderDescription包含給定點邊界類型的簡單point類型,看BorderEstimation以獲得更多信息。

struct
{int x, y;BorderTraitstraits;
};

26.IntensityGradient

成員變量:float gradient[3];
IntensityGradient包含給定點強度的梯度point類型,查看IntensityGradientEstimation以獲得更多信息。

struct
{union{float gradient[3];struct{float gradient_x;float gradient_y;float gradient_z;};};
};

27.Histogram

成員變量:float histogram[N];
Histogram用來存儲一般用途的n維直方圖

template<int N>
struct Histogram
{float histogram[N];
};

28.PointWithScale

成員變量:float x, y, z, scale;
PointWithScale除了scale表示某點用于幾何操作的尺度(例如,計算最近鄰所用的球體半徑,窗口尺寸等等),其它的和PointXYZI一樣。

struct
{union{float data[4];struct{float x;float y;float z;};};float scale;
};

29.PointSurfel

成員變量:float x, y, z, normal[3], rgba, radius, confidence, curvature;
PointSurfel存儲XYZ坐標、曲面法線、RGB信息、半徑、可信度和曲面曲率的復雜point類型。

union
{float data[4];struct{float x;float y;float z;};
};
union
{float data_n[4];float normal[3];struct{float normal_x;float normal_y;float normal_z;};
};
union
{struct{uint32_trgba;float radius;float confidence;float curvature;};float data_c[4];
};

PS.自定義一個點云PointT類型

#define PCL_NO_PRECOMPILE
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/io/pcd_io.h>struct MyPointType
{PCL_ADD_POINT4D;                  // 添加pcl里xyz+paddingfloat test;EIGEN_MAKE_ALIGNED_OPERATOR_NEW   // 確保定義新類型點云內存與SSE對齊
} EIGEN_ALIGN16;                    // 強制SSE填充以正確對齊內存POINT_CLOUD_REGISTER_POINT_STRUCT (MyPointType,           // 定義新類型里元素包括XYZ+“test”(float, x, x)(float, y, y)(float, z, z)(float, test, test)
)int
main (int argc, char** argv)//興建一個新的點云文件,包括兩個新定義點云類型的點
{pcl::PointCloud<MyPointType> cloud;//初始化點云類型cloud.points.resize (2);cloud.width = 2;cloud.height = 1;//height為1表示無組織下的點云文件,cloud.points[0].test = 1;cloud.points[1].test = 2;cloud.points[0].x = cloud.points[0].y = cloud.points[0].z = 0;cloud.points[1].x = cloud.points[1].y = cloud.points[1].z = 3;pcl::io::savePCDFile ("test.pcd", cloud);//存儲
}

?

總結

以上是生活随笔為你收集整理的PCL基础1:点云数据结构的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。