我一直在关注教程http://pointclouds.org/documentation/tutorials/pcl_visualizer.php#pcl-visualizer,可以让一个简单的查看器工作。
我查看了文档,发现函数getMatrixXfMap
从Eigen::MatrixXf
返回PointCloud
。
// Get Eigen matrix
Eigen::MatrixXf M = basic_cloud_ptr->getMatrixXfMap();
cout << "(Eigen) #row :" << M.rows() << endl;
cout << "(Eigen) #col :" << M.cols() << endl;
接下来我处理M
(基本上是轮换,翻译和其他一些变换)。我如何有效地将M
设置为PointCloud
。或者我需要一次pushback()
一点吗?
答案 0 :(得分:1)
您不需要将您的pcl云投射到Eigen :: MatrixXF,进行转换并退回。您只需在输入云上执行:
pcl::PointCloud<pcl::PointXYZ>::Ptr source_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
\\ Fill the cloud
\\ .....
Eigen::Affine3f transform_2 = Eigen::Affine3f::Identity();
// Define a translation of 2.5 meters on the x axis.
transform_2.translation() << 2.5, 0.0, 0.0;
// The same rotation matrix as before; theta radians arround Z axis
transform_2.rotate (Eigen::AngleAxisf (theta, Eigen::Vector3f::UnitZ()));
// Print the transformation
printf ("\nMethod #2: using an Affine3f\n");
std::cout << transform_2.matrix() << std::endl;
// Executing the transformation
pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
// You can either apply transform_1 or transform_2; they are the same
pcl::transformPointCloud (*source_cloud, *transformed_cloud, transform_2);