本文介绍了使用Eigen Vector3d容器创建PCL点云的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试生成PCL点云.我所有的观点都在以下容器类型中:

I am trying to generate a PCL point cloud. All my points are in the following container type:

std::vector<Eigen::Vector3d,Eigen::aligned_allocator<Eigen::Vector3d> >

我想创建一个指向PCL点云的指针:

I would like to create a pointer to a PCL point cloud:

pcl::PointCloud<pcl::PointXYZ>::Ptr pc

创建此点云的最有效方法是什么?

What would be the most efficient way to create this point cloud?

推荐答案

由于PCL似乎使​​用float [4]存储点,因此当您指定pcl:PointXYZ时,您将必须分别复制每个元素(未经测试) ):

Since PCL seems to use a float[4] to store the points, when you specify pcl:PointXYZ, you will have to copy each element individually (not tested):

pc.points.resize( v.size() );
for(size_t i=0; i<v.size(); ++i)
    pc.points[i].getVector3fMap() = v[i].cast<float>();

如果改用vector4d并确保每个元素的最后一个系数为0,则可以执行memcpy甚至交换操作(有些技巧).

if you used a vector4d instead and ensured that the last coefficient of each element is 0, you could do a memcpy or even a swap (with a bit of trickery).

这篇关于使用Eigen Vector3d容器创建PCL点云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 02:46