关闭

learn pcl 03

180人阅读 评论(0) 收藏 举报

前两篇是在做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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2098次
    • 积分:68
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档