【问题标题】:Eigen with PointCloud (PCL)特征点云 (PCL)
【发布时间】:2015-03-26 09:15:09
【问题描述】:

我一直在关注http://pointclouds.org/documentation/tutorials/pcl_visualizer.php#pcl-visualizer 教程,并且可以让一个简单的查看器正常工作。

我查阅了文档并找到了函数getMatrixXfMap,它从PointCloud 返回Eigen::MatrixXf

// 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()

【问题讨论】:

  • 只要使用Eigen::Matrix4f trans;就可以随意设置矩阵。 pcl::transformPointCloud(*beforeTransCloud,*afterTransCloud,trans)
  • 如果我的操作不像线性变换那么简单怎么办?如何将点云检索为矩阵进行操作?
  • 然后确实使用push_back,或者更有效地使用cloud-&gt;resize,然后每点cloud-&gt;points[i].x = ...

标签: eigen point-cloud-library eigen3


【解决方案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);

取自pcl transformation tutorial

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多