Search code examples
c++point-cloud-library

how to make our own Point Type with PCL 1.9


I was following this tutorial to make it. But I think it is deprecated since you have to

#include <pcl/memory.h>

Which has been remove since PCL 1.8. I didn't find other tutorial to bypass this problem.

I need to make a new Point Type which can contain 15 other scalars as parameter in addition to its XYZ coordinates, its normals and its colors.

After that I import a new point cloud which is already written on my disk, which contains points with the same parameters. With this point type I can use it.


Solution

  • After struggling a bit here's how I solved it :

    You DO NOT

    #include <memory.h>
    

    It seems to be deprecated for the reason I've mentionned.

    I suggest you to follow this tutorial

    Therefore if you create your own point type your code will look like this :

    struct MyPointType
    {
        PCL_ADD_POINT4D;                  // preferred way of adding a XYZ+padding
        PCL_ADD_RGB;                    //if you want to add colors, you'd better use that
    
        float the_exact_name_of_the_scalar1;
        float the_exact_name_of_the_scalar2;
    
        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,rgb,rgb)                                      //colors
        (float, the_exact_name_of_the_scalar1, the_exact_name_of_the_scalar1)
        (float, the_exact_name_of_the_scalar2, the_exact_name_of_the_scalar2)
    )
    

    Then you can use MyPointType exactly like a classic point type.

    With PCL 1.9 you should use

    EIGEN_MAKE_ALIGNED_OPERATOR_NEW     
    

    instead of

    PCL_MAKE_ALIGNED_OPERATOR_NEW