#include <PointCloud.h>
Alson 点云类
支持基础的读写、遍历操作,可以与 Pcl 点云类互相转换。转换操作参见 createFromPcl
- 自从
- 0.3.0
在文件 PointCloud.h 第 73 行定义.
◆ PointCloud() [1/5]
ALSON::PointCloud::PointCloud |
( |
| ) |
|
◆ PointCloud() [2/5]
ALSON::PointCloud::PointCloud |
( |
int | w, |
|
|
int | h, |
|
|
PointType | t ) |
创建一个指定宽、高、点类型的点云
- 参数
-
- 自从
- 0.3.0
◆ PointCloud() [3/5]
ALSON::PointCloud::PointCloud |
( |
int | w, |
|
|
int | h, |
|
|
PointType | t, |
|
|
uint8_t * | d ) |
创建一个指定宽、高、类型、数据的点云
- 注意
- 使用该接口可以设置外部数据指针,但数据的生命周期不再由 PointCloud 管理
- 参数
-
w | 指定点云的宽度 |
h | 指定点云的高度 |
t | 点云类型 |
d | 点云数据 |
- 自从
- 0.4.0
◆ ~PointCloud()
ALSON::PointCloud::~PointCloud |
( |
| ) |
|
◆ PointCloud() [4/5]
ALSON::PointCloud::PointCloud |
( |
const PointCloud & | a | ) |
|
◆ PointCloud() [5/5]
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ size()
int ALSON::PointCloud::size |
( |
| ) |
const |
|
inline |
◆ ptr() [1/2]
template<typename T >
T * ALSON::PointCloud::ptr |
( |
| ) |
|
|
inline |
获取指向点云数据的指针
通过该指针可以遍历点云数据,如下示例代码展示了如何遍历点云数据
pointCloud.
load(
"./testPointCloud.pcd");
int totalElements = pointCloud.
size();
for (int i = 0; i < totalElements; ++i, ++p1) {
float x = p1->x;
float y = p1->y;
float z = p1->z;
std::cout << " x : " << x << " y : " << y << " z : " << z << std::endl
}
static PointCloud load(const std::string &filename, PointType pointType=PointType::ALSON_POINT_XYZ)
- 模板参数
-
- 返回
- 指向点云数据的指针
- 自从
- 0.3.0
在文件 PointCloud.h 第 772 行定义.
◆ ptr() [2/2]
template<typename T >
const T * ALSON::PointCloud::ptr |
( |
| ) |
const |
|
inline |
◆ at() [1/2]
template<typename T >
T & ALSON::PointCloud::at |
( |
int | i, |
|
|
int | j = 0 ) |
|
inline |
◆ at() [2/2]
template<typename T >
const T & ALSON::PointCloud::at |
( |
int | i, |
|
|
int | j = 0 ) const |
|
inline |
◆ create() [1/2]
创建一个指定宽、高、点类型的点云
- 参数
-
- 返回
- 点云
- 自从
- 0.4.0
◆ create() [2/2]
static PointCloud ALSON::PointCloud::create |
( |
int | width, |
|
|
int | height, |
|
|
PointType | pointType, |
|
|
uint8_t * | data ) |
|
static |
创建一个指定宽、高、类型、数据的点云
- 注意
- 使用该接口可以设置外部数据指针,但数据的生命周期不再由 PointCloud 管理
- 参数
-
w | 指定点云的宽度 |
h | 指定点云的高度 |
t | 点云类型 |
d | 点云数据 |
- 自从
- 0.4.0
◆ createFromPcl()
static PointCloud ALSON::PointCloud::createFromPcl |
( |
int | width, |
|
|
int | height, |
|
|
PointType | pointType, |
|
|
void * | pclData ) |
|
static |
使用 Pcl 点云创建一个 Alson 点云
如下示例代码展示了该接口的使用方式
pcl::PointCloud<pcl::PointXYZ>::Ptr pclPointCloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile("./testPointCloud.pcd", *pclPointCloud);
static PointCloud createFromPcl(int width, int height, PointType pointType, void *pclData)
- 参数
-
width | 点云的宽度 |
height | 点云的高度 |
pointType | 点类型 |
pclData | Pcl 格式的点云数据 |
- 返回
- 点云
- 异常
-
- 自从
- 0.4.0
◆ clone()
◆ cloneToPcl()
void ALSON::PointCloud::cloneToPcl |
( |
void * | pclData, |
|
|
PclPointType | pclPointType ) const |
深拷贝当前点云数据到 Pcl 点云中
如下示例代码展示了该接口的使用方式
pointCloud.
load(
"./testPointCloud.pcd");
pcl::PointCloud<pcl::PointXYZ> pc(pointCloud.
width, pointCloud.
height);
void cloneToPcl(void *pclData, PclPointType pclPointType) const
- 参数
-
pclData | Pcl 点云数据 |
pclPointType | Pcl 点类型 |
- 异常
-
- 自从
- 0.4.0
◆ load()
从本地文件加载点云
如下示例代码展示了该接口的使用方式
pointCloud.
load(
"./testPointCloud.pcd");
- 注意
- 目前该接口支持加载 ply 和 pcd 格式的点云,要求点云文件的后缀为 \( .ply \) 或 \( .pcd \)
- 参数
-
filename | 点云文件路径 |
pointType | 点类型 |
- 返回
- 点云
- 异常
-
- 自从
- 0.4.0
◆ save()
void ALSON::PointCloud::save |
( |
const std::string & | filename | ) |
const |
将当前点云保存到本地文件
如下示例代码展示了该接口的使用方式
pointCloud.
save(
"./testPointCloud.pcd");
void save(const std::string &filename) const
- 注意
- 目前该接口保存加载 ply 和 pcd 格式的点云,要求点云文件的后缀为 \( .ply \) 或 \( .pcd \)
- 参数
-
- 异常
-
- 自从
- 0.4.0
◆ getXPos()
int ALSON::PointCloud::getXPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 X 字段的字节偏移量
如果点结构中存在 X 字段,则返回 X 字段的偏移量,否则返回 -1
使用 getXXX 系列接口可以以一种特殊的方式遍历点云,如下示例代码展示了这种用法
int totalElements = pointCloud.
size();
uint8_t* p1 = pointCloud.
data;
for (int i = 0; i < totalElements; ++i) {
float x = *(float*) (p1 + xPos) ;
float y = *(float*) (p1 + yPos) ;
float z = *(float*) (p1 + zPos) ;
int r = *(p1 + rPos) ;
int g = *(p1 + gPos) ;
int b = *(p1 + bPos) ;
float nx = *(float*) (p1 + nxPos) ;
float ny = *(float*) (p1 + nyPos) ;
float nz = *(float*) (p1 + nzPos) ;
}
- 返回
- 点结构中 X 字段的字节偏移量
- 自从
- 0.4.0
◆ getYPos()
int ALSON::PointCloud::getYPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 Y 字段的字节偏移量
如果点结构中存在 Y 字段,则返回 Y 字段的偏移量,否则返回 -1
- 返回
- 点结构中 Y 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getZPos()
int ALSON::PointCloud::getZPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 Z 字段的字节偏移量
如果点结构中存在 Z 字段,则返回 Z 字段的偏移量,否则返回 -1
- 返回
- 点结构中 Z 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getIPos()
int ALSON::PointCloud::getIPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 I 字段的字节偏移量
如果点结构中存在 I 字段,则返回 I 字段的偏移量,否则返回 -1
- 返回
- 点结构中 I 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getRPos()
int ALSON::PointCloud::getRPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 R 字段的字节偏移量
如果点结构中存在 R 字段,则返回 R 字段的偏移量,否则返回 -1
- 返回
- 点结构中 R 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getGPos()
int ALSON::PointCloud::getGPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 G 字段的字节偏移量
如果点结构中存在 G 字段,则返回 G 字段的偏移量,否则返回 -1
- 返回
- 点结构中 G 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getBPos()
int ALSON::PointCloud::getBPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 B 字段的字节偏移量
如果点结构中存在 B 字段,则返回 B 字段的偏移量,否则返回 -1
- 返回
- 点结构中 B 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getNXPos()
int ALSON::PointCloud::getNXPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 NX 字段的字节偏移量
如果点结构中存在 NX 字段,则返回 NX 字段的偏移量,否则返回 -1
- 返回
- 点结构中 NX 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getNYPos()
int ALSON::PointCloud::getNYPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 NY 字段的字节偏移量
如果点结构中存在 NY 字段,则返回 NY 字段的偏移量,否则返回 -1
- 返回
- 点结构中 NY 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getNZPos()
int ALSON::PointCloud::getNZPos |
( |
| ) |
const |
在当前点云数据中,获取点结构中 NZ 字段的字节偏移量
如果点结构中存在 NZ 字段,则返回 NZ 字段的偏移量,否则返回 -1
- 返回
- 点结构中 NZ 字段的字节偏移量
- 自从
- 0.4.0
- 参见
- getXPos
◆ getElementSize()
static int ALSON::PointCloud::getElementSize |
( |
PointType | type | ) |
|
|
static |
◆ width
int ALSON::PointCloud::width |
◆ height
int ALSON::PointCloud::height |
◆ type
◆ elementSize
int ALSON::PointCloud::elementSize |
◆ data
uint8_t* ALSON::PointCloud::data |