PCL点云库增加自定义数据类型

#include <pcl/filters/passthrough.h>
#include <pcl/filters/impl/passthrough.hpp>
// the rest of the code goes here
如果你的代码是库的一部分,可以被他人使用,需要为你自己的MyPointType类型进行显示实例化。
实例
下面的代码段创建了包含XYZ数据的新point类型,连同一个的test的浮点型数据,这样满足存储对齐。
#include <pcl/point_types.h>
 #include <pcl/point_cloud.h>
 #include <pcl/io/pcd_io.h>
 
struct MyPointType              //定义点类型结构
{
PCL_ADD_POINT4D;                // 该点类型有4个元素
float test;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW// 确保new操作符对齐操作
}EIGEN_ALIGN16;// 强制SSE对齐
 
POINT_CLOUD_REGISTER_POINT_STRUCT(MyPointType,// 注册点类型宏
(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;
 
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);
}

转:   http://www.pclcn.org/study/shownews.php?lang=cn&id=286

posted @ 2015-03-24 22:04  lwn6  阅读(3505)  评论(0)    收藏  举报
什么是幸福?天天在做自己想做的事情,家人、同事、朋友、客户、网友都和和睦睦,身体健康、钱包鼓鼓、女朋友天天开心、生活无忧无虑就是最大的幸福