PCL:添加自定义点类型
Posted 没事就要敲代码
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PCL:添加自定义点类型相关的知识,希望对你有一定的参考价值。
简单记录一下
#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; // preferred way of adding a XYZ+padding
float test;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW // make sure our new allocators are aligned 确保new操作符对齐操作
} EIGEN_ALIGN16; // enforce SSE padding for correct memory alignment 强制SSE对齐
POINT_CLOUD_REGISTER_POINT_STRUCT(MyPointType, // here we assume a XYZ + "test" (as fields) 注册点类型宏
(float, x, x)
(float, y, y)
(float, z, z)
(float, test, test)
)
int main()
{
pcl::PointCloud<MyPointType> cloud;
cloud.resize(2);
cloud.width = 2;
cloud.height = 1;
cloud[0].test = 1;
cloud[1].test = 2;
cloud[0].x = cloud[0].y = cloud[0].z = 0;
cloud[1].x = cloud[1].y = cloud[1].z = 3;
pcl::io::savePCDFile("test.pcd", cloud);
return 0;
}
官网链接:http://pointclouds.org/documentation/tutorials/adding_custom_ptype.html#adding-custom-ptype
以上是关于PCL:添加自定义点类型的主要内容,如果未能解决你的问题,请参考以下文章