learn pcl 03

本文介绍了如何在PCL中添加自定义的PointT类型,包括PointXYZ数据类型的成员(浮点型x, y, z)以及SSE对齐。通过示例展示了创建包含XYZ和测试浮点型的新点类型。" 84993400,7789980,指数分布与泊松过程详解,"['概率论', '统计学', '随机过程', '数学模型', '数据分析']
摘要由CSDN通过智能技术生成

前两篇是在做independent study topic presentation时所学习。 现在开始进入正式学习,都是按照pcl网站上的tutorial。所以这些文章也只是笔记。

Adding your own custom PointT type

  • PointXYZ - Members: float x, y, z;

    This is one of the most used data types, as it represents 3D xyz information only. The 3 floats are padded with an additional float for SSE alignment. The user can either access points[i].data[0] or points[i].x for accessing say, the x coordinate.

union
{
  float data[4];
  struct
  {
    float x;
    float y;
    float z;
  };
};

How to add a new PointT type


Example

The following code snippet example creates a new point type that contains XYZ data (SSE padded), together with a test float.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 #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
 } EIGEN_ALIGN16;                    // enforce SSE padding for correct memory alignment

 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 (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);
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值