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> >
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?
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>();
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With