我的问题与Creating a PCL point cloud using a container of Eigen Vector3d有关,但我使用的是Eigen::MatrixXd而不是Eigen::Vector3d。getMatrixXfMap()不是成员函数的一部分,因此不能代替getVector3fMap()使用。在这种情况下,如何转换类型?
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// resize to number of points
cloud->points.resize(Pts.rows());
/*DOES NOT WORK */
for(int i=0;i<Pts.rows();i++)
cloud->points[i].getMatrixXfMap() = Pts[i].cast<float>();发布于 2015-02-12 12:25:57
这可能不是很吸引人,但为什么不在for循环中创建每个点呢?在这种情况下不需要调整大小。
pcl::PointXYZ temp;
temp.x = Pts[i][0];
temp.y = Pts[i][1];
temp.z = Pts[i][2];
cloud.push_back(temp);发布于 2021-11-17 09:16:34
这就是我所做的。我的source_cloud是一个包含float32格式的XYZ点的Nx3矩阵。
typedef pcl::PointCloud<pcl::PointXYZRGBA> PointCloudRGBA;
Eigen::MatrixXf convertToPointCloud(const Eigen::MatrixXf source_cloud){
PointCloudRGBA::Ptr cloud(new PointCloudRGBA);
cloud->points.resize(source_cloud.rows());
for(int i=0; i<source_cloud.rows(); i++){
cloud->points[i].getVector3fMap() = Eigen::Vector3d(source_cloud(i, 0), source_cloud(i, 1), source_cloud(i, 2)).cast<float>();
}
}https://stackoverflow.com/questions/28174974
复制相似问题