gpt4 book ai didi

c++ - PCL 为所有函数实例化新的点类型

转载 作者:行者123 更新时间:2023-11-30 03:38:52 26 4
gpt4 key购买 nike

我在下面声明了一个新的点类型。但是,我需要它来处理所有可用的 PCL 函数。例如分割、体素网格等。包含所有执行 header 以执行 PCL_INSTANTIATE 调用是一件痛苦的事情。无论如何都要为所有主要功能做这个?比如把我的point类型编译成segmentation库里的所有函数?

    #define PCL_NO_PRECOMPILE

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/impl/instantiate.hpp>

#include <pcl/kdtree/kdtree.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/kdtree/impl/kdtree_flann.hpp>
#include <pcl/search/impl/kdtree.hpp>

#include <pcl/octree/octree_search.h>
#include <pcl/octree/impl/octree_search.hpp>

#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/segmentation/impl/sac_segmentation.hpp>

struct FeaturePoint
{
PCL_ADD_POINT4D;
PCL_ADD_RGB;
PCL_ADD_NORMAL4D;

static const int DESCRIPTOR_SIZE = 128;
float descriptor[DESCRIPTOR_SIZE];

FeaturePoint() {}
FeaturePoint(const FeaturePoint& input)
{
this->x = input.x;
this->y = input.y;
this->z = input.z;
this->rgb = input.rgb;
this->normal_x = input.normal_x;
this->normal_y = input.normal_y;
this->normal_z = input.normal_z;
for(int i = 0; i < DESCRIPTOR_SIZE; ++i) { this->descriptor[i] = input.descriptor[i]; } // Ugly, as I was lazy
}

EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
} EIGEN_ALIGN16;

POINT_CLOUD_REGISTER_POINT_STRUCT (FeaturePoint,
(float, x, x)
(float, y, y)
(float, z, z)
(float, rgb, rgb)
(float, normal_x, normal_x)
(float, normal_y, normal_y)
(float, normal_z, normal_z)
(float, descriptor, descriptor)
);

PCL_INSTANTIATE(KdTree, FeaturePoint);
PCL_INSTANTIATE(KdTreeFLANN, FeaturePoint);
PCL_INSTANTIATE(OctreePointCloudSearch, FeatureP

最佳答案

更新:在尝试了几个小时的解决方案后,这对所有功能都正常工作:

PCLapp.h 中的代表性代码部分:

include pcl-1.8/pcl/point_cloud.h
include pcl-1.8/pcl/point_types.h
include pcl-1.8/pcl/filters/voxel_grid.h
include boost/shared_ptr.hpp

namespace pcl{

struct PointXYZIR
{
PCL_ADD_POINT4D // Macro quad-word XYZ
float intensity; // Laser intensity
uint16_t ring; // Laser ring number
EIGEN_MAKE_ALIGNED_OPERATOR_NEW // Ensure proper alignment
} EIGEN_ALIGN16;
}

POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZIR,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(uint16_t, ring, ring)
)


typedef pcl::PointCloud<pcl::PointXYZIR> PointCloudXYZIR;

### I didn't include any .hpp file (like tutorial said)

PCLapp.cpp 中的代表性代码部分(VoxelGrid 示例)

boost::shared_ptr<PointCloudXYZIR> input_cloud(new PointCloudXYZIR);
PointCloudXYZIR::ConstPtr input_cloudPtr(input_cloud);

pcl::VoxelGrid<pcl::PointXYZIR> vox;
vox.setInputCloud(input_cloudPtr);
vox.setLeafSize(0.05,0.05,0.05);
vox.filter(*input_cloud);

这与所有过滤器完美配合,无需执行任何其他操作。

关于c++ - PCL 为所有函数实例化新的点类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39221424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com