Eigen与PointCloud(PCL) [英] Eigen with PointCloud (PCL)

查看:748
本文介绍了Eigen与PointCloud(PCL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have been following the tutorial http://pointclouds.org/documentation/tutorials/pcl_visualizer.php#pcl-visualizer and could get a simple viewer working.

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

I looked up the documentation and found the function getMatrixXfMap which returns the Eigen::MatrixXf from a 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()一分?

Next I process M (basically rotations, translations and some other transforms). I how is possible to set M into the PointCloud efficiently. Or is it that I need to pushback() one point at a time?

推荐答案

您无需将pcl云转换为Eigen :: MatrixXF,无需进行转换并重新转换.您只需在输入云上执行即可:

You do not need to cast your pcl cloud to an Eigen::MatrixXF, do the tranformations and cast back. You can simply perform on your input cloud:

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转换教程.

这篇关于Eigen与PointCloud(PCL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆