0.4.3
ALSON::PointCloud类 参考

#include <PointCloud.h>

Public 成员函数

 PointCloud ()
 
 PointCloud (int w, int h, PointType t)
 
 PointCloud (int w, int h, PointType t, uint8_t *d)
 
 ~PointCloud ()
 
 PointCloud (const PointCloud &a)
 
PointCloudoperator= (const PointCloud &a)
 
 PointCloud (PointCloud &&a) noexcept
 
PointCloudoperator= (PointCloud &&a) noexcept
 
int size () const
 
template<typename T >
T * ptr ()
 
template<typename T >
const T * ptr () const
 
template<typename T >
T & at (int i, int j=0)
 
template<typename T >
const T & at (int i, int j=0) const
 
PointCloud clone () const
 
void cloneToPcl (void *pclData, PclPointType pclPointType) const
 
void save (const std::string &filename) const
 
int getXPos () const
 
int getYPos () const
 
int getZPos () const
 
int getIPos () const
 
int getRPos () const
 
int getGPos () const
 
int getBPos () const
 
int getNXPos () const
 
int getNYPos () const
 
int getNZPos () const
 

静态 Public 成员函数

static PointCloud create (int width, int height, PointType pointType)
 
static PointCloud create (int width, int height, PointType pointType, uint8_t *data)
 
static PointCloud createFromPcl (int width, int height, PointType pointType, void *pclData)
 
static PointCloud load (const std::string &filename, PointType pointType=PointType::ALSON_POINT_XYZ)
 
static int getElementSize (PointType type)
 

Public 属性

int width
 
int height
 
PointType type
 
int elementSize
 
uint8_t * data
 

详细描述

Alson 点云类

支持基础的读写、遍历操作,可以与 Pcl 点云类互相转换。转换操作参见 createFromPcl

自从
0.3.0

在文件 PointCloud.h73 行定义.

构造及析构函数说明

◆ PointCloud() [1/5]

ALSON::PointCloud::PointCloud ( )

创建一个空的点云

自从
0.3.0

◆ PointCloud() [2/5]

ALSON::PointCloud::PointCloud ( int w,
int h,
PointType t )

创建一个指定宽、高、点类型的点云

参数
w点云的宽度
h点云的高度
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]

ALSON::PointCloud::PointCloud ( PointCloud && a)
noexcept

成员函数说明

◆ operator=() [1/2]

PointCloud & ALSON::PointCloud::operator= ( const PointCloud & a)

◆ operator=() [2/2]

PointCloud & ALSON::PointCloud::operator= ( PointCloud && a)
noexcept

◆ size()

int ALSON::PointCloud::size ( ) const
inline

获取当前点云对象中的点数量

返回
点数量
自从
0.3.0

在文件 PointCloud.h151 行定义.

◆ ptr() [1/2]

template<typename T >
T * ALSON::PointCloud::ptr ( )
inline

获取指向点云数据的指针

通过该指针可以遍历点云数据,如下示例代码展示了如何遍历点云数据

PointCloud pointCloud;
pointCloud.load("./testPointCloud.pcd");
int totalElements = pointCloud.size();
auto* p1 = pointCloud.ptr<PointXYZ>();
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)
模板参数
T点类型
返回
指向点云数据的指针
自从
0.3.0

在文件 PointCloud.h772 行定义.

◆ ptr() [2/2]

template<typename T >
const T * ALSON::PointCloud::ptr ( ) const
inline

获取指向点云数据的指针

模板参数
T点类型
返回
指向点云数据的指针
自从
0.4.0

在文件 PointCloud.h777 行定义.

◆ at() [1/2]

template<typename T >
T & ALSON::PointCloud::at ( int i,
int j = 0 )
inline

在当前点云中获取指定位置点的引用

模板参数
T点类型
参数
i横坐标
j纵坐标
返回
点的引用
自从
0.3.0

在文件 PointCloud.h782 行定义.

◆ at() [2/2]

template<typename T >
const T & ALSON::PointCloud::at ( int i,
int j = 0 ) const
inline

在当前点云中获取指定位置点的引用

模板参数
T点类型
参数
i横坐标
j纵坐标
返回
点的常量引用
自从
0.3.0

在文件 PointCloud.h788 行定义.

◆ create() [1/2]

static PointCloud ALSON::PointCloud::create ( int width,
int height,
PointType pointType )
static

创建一个指定宽、高、点类型的点云

参数
w点云的宽度
h点云的高度
t点类型
返回
点云
自从
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);
PointCloud pointCloud = PointCloud::createFromPcl((int) pclPointCloud.width, (int) pclPointCloud.height, PointType::ALSON_POINT_XYZ, pclPointCloud);
static PointCloud createFromPcl(int width, int height, PointType pointType, void *pclData)
@ ALSON_POINT_XYZ
x、y、z
参数
width点云的宽度
height点云的高度
pointType点类型
pclDataPcl 格式的点云数据
返回
点云
异常
CommonException
自从
0.4.0

◆ clone()

PointCloud ALSON::PointCloud::clone ( ) const

深拷贝当前点云对象

返回
新的点云
自从
0.4.0

◆ cloneToPcl()

void ALSON::PointCloud::cloneToPcl ( void * pclData,
PclPointType pclPointType ) const

深拷贝当前点云数据到 Pcl 点云中

如下示例代码展示了该接口的使用方式

PointCloud pointCloud;
pointCloud.load("./testPointCloud.pcd");
pcl::PointCloud<pcl::PointXYZ> pc(pointCloud.width, pointCloud.height);
pointCloud.cloneToPcl(pc.points.data(), PclPointType::PCL_POINT_XYZ);
void cloneToPcl(void *pclData, PclPointType pclPointType) const
@ PCL_POINT_XYZ
x、y、z
参数
pclDataPcl 点云数据
pclPointTypePcl 点类型
异常
CommonException
自从
0.4.0

◆ load()

static PointCloud ALSON::PointCloud::load ( const std::string & filename,
PointType pointType = PointType::ALSON_POINT_XYZ )
static

从本地文件加载点云

如下示例代码展示了该接口的使用方式

PointCloud pointCloud;
pointCloud.load("./testPointCloud.pcd");
注意
目前该接口支持加载 ply 和 pcd 格式的点云,要求点云文件的后缀为 \( .ply \) 或 \( .pcd \)
参数
filename点云文件路径
pointType点类型
返回
点云
异常
CommonException
自从
0.4.0

◆ save()

void ALSON::PointCloud::save ( const std::string & filename) const

将当前点云保存到本地文件

如下示例代码展示了该接口的使用方式

PointCloud pointCloud;
pointCloud.save("./testPointCloud.pcd");
void save(const std::string &filename) const
注意
目前该接口保存加载 ply 和 pcd 格式的点云,要求点云文件的后缀为 \( .ply \) 或 \( .pcd \)
参数
filename点云文件路径
异常
CommonException
自从
0.4.0

◆ getXPos()

int ALSON::PointCloud::getXPos ( ) const

在当前点云数据中,获取点结构中 X 字段的字节偏移量

如果点结构中存在 X 字段,则返回 X 字段的偏移量,否则返回 -1

使用 getXXX 系列接口可以以一种特殊的方式遍历点云,如下示例代码展示了这种用法

PointCloud pointCloud;
int totalElements = pointCloud.size();
int xPos = this->getXPos();
int yPos = this->getYPos();
int zPos = this->getZPos();
int rPos = this->getRPos();
int gPos = this->getGPos();
int bPos = this->getBPos();
int nxPos = this->getNXPos();
int nyPos = this->getNYPos();
int nzPos = this->getNZPos();
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) ;
p1 += elementSize;
}
int getXPos() const
int getGPos() const
int getZPos() const
int getNYPos() const
int getRPos() const
int getNXPos() const
int getYPos() const
int getNZPos() const
int getBPos() const
返回
点结构中 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

获取指定点类型的字节大小

参数
type点类型
返回
字节大小
自从
0.3.0
参见
elementSize

类成员变量说明

◆ width

int ALSON::PointCloud::width

点云的宽

自从
0.3.0

在文件 PointCloud.h711 行定义.

◆ height

int ALSON::PointCloud::height

点云的高

如果高不为1,点云为有序点云,否则点云为无序点云

自从
0.3.0

在文件 PointCloud.h726 行定义.

◆ type

PointType ALSON::PointCloud::type

点类型

自从
0.3.0

在文件 PointCloud.h738 行定义.

◆ elementSize

int ALSON::PointCloud::elementSize

当前点云中每个点的字节大小

自从
0.3.0
参见
getElementSize

在文件 PointCloud.h751 行定义.

◆ data

uint8_t* ALSON::PointCloud::data

点云数据

自从
0.3.0

在文件 PointCloud.h763 行定义.

My Custom Doxygen Footer
Data Processing Programmer's Guide 0.4.3
Copyright © 2014-2024 Henan Alson Intelligent Technology Co, Ltd 河南埃尔森智能科技有限公司 版权所有 豫ICP备15002212号