pcl之自定义pointT类型

available point types in PCL

  • PointXYZ - Members: float x, y, z;
  • PointXYZI - Members: float x, y, z, intensity;
  • PointXYZRGBA - Members: float x, y, z; uint32_t rgba;
  • PointXYZRGB - float x, y, z, rgb;
  • PointXY - float x, y;
  • PointNormal - float x, y, z; float normal[3], curvature;
  • PointXYZINormal - float x, y, z, intensity, normal[3], curvature;
  • PointXYZRGBNormal - float x, y, z, rgb, normal[3], curvature;

Therefore for SSE-alignment, we pad intensity with 3 extra floats. Inefficient in terms of storage, but good in terms of memory alignment.

add custom point type

example:

#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 intensity;
  uint16_t ring;
  float range;
  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,        
                                   (float, x, x)
                                   (float, y, y)
                                   (float, z, z)
                                   (float, intensity, intensity)
                                   (uint16_t, ring, ring)
                                   (float, range, range));


int main (int argc, char** argv)
{
  pcl::PointCloud<MyPointType> cloud;
  cloud.points.resize (2);
  cloud.width = 2;
  cloud.height = 1;

  cloud.points[0].ring = 1;
  cloud.points[1].range = 2.1;
  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://pointclouds.org/documentation/tutorials/adding_custom_ptype.php

pcl之自定义pointT类型

上一篇:固体物理复习(一)晶体结构描述和布拉格定律


下一篇:浅析VUE里的插槽