My ultimate goal is to convert very efficiently a Point Cloud pcl::PointCloud<pcl::PointXYZ>
to std::vector<Eigen::Vector3f>
.
The function getMatrixXfMap()
(link) allows me to convert the Point Cloud to a Eigen::MatrixXf
.
How could I convert now the Eigen::MatrixXf
into a std::vector<Eigen::Vector3f>
? (or if you know a direct method to go from the pcl::PointCloud<pcl::PointXYZ>
to std::vector<Eigen::Vector3f>
that also works for me)
This answer is exactly the other way around
UPDATE: This is what I have so far (it works, but it's slower than iterating through all the points). I'm casting to double in this case, but any solution without casting to double also works for me:
pcl::PointCloud<pcl::PointXYZ>::Ptr pclptr_map_;
// Do stuff
Eigen::MatrixXd mat = (pclptr_map_->getMatrixXfMap()).cast<double>();
int cols = pclptr_map_->points.size();
std::vector<Eigen::Vector3d> v(pclptr_map_->points.size());
Eigen::Matrix<double, 3, Eigen::Dynamic>::Map(v.data()->data(), 3, cols) = mat;
Thanks