1,使用基础点云类型
#include "pcl/point_types.h"
#include "pcl/impl/instantiate.hpp"
#include "foo.h"
#include "impl/foo.hpp"
template class Foo<pcl::PointXYZ>;
2,定义新的点云类型
struct MyPointType
{
float test;
};
3,自己定义的类型能够使用PCL里的模板算法
#define PCL_NO_PRECOMPILE
#include <pcl/filters/passthrough.h>
#include <pcl/filters/impl/passthrough.hpp>
//coding
4,用法实例
#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+padding
float 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);//存储
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)