我有一个来自kinect融合的点云,并使用Point Cloud Library成功分割地平面(a x + b y + c * z + d = 0)(我得到了a, b,c,d在pcl ::地面平面的模型系数中)。现在我需要将笛卡尔坐标转换为新的笛卡尔坐标,使地平面成为X-O-Y平面(0 * x + 0 * y + z = 0)。 我想我可以通过这个API做到(但我不知道如何): http://docs.pointclouds.org/trunk/group__common.html#transformPointCloud
我的回答: 看看这个PCL api:http://docs.pointclouds.org/1.7.2/a02405.html#ga4375e99ec2ae368eec9379f506568611
我成功解决了这个问题!
答案 0 :(得分:0)
我无法打开您的API链接,但您猜测可以使用简单的转换来转换平面:
答案 1 :(得分:0)
此功能需要相机姿势,即4x4矩阵,格式为
| R t |
| 0 1 |
这里,R是3x3旋转矩阵,t是3x1平移向量,0 - 是0x的1x3向量,1是单位(标量)。
您应该以这样的方式设计此矩阵,即新坐标系中的Z轴将与平面的法向量共线。新的X轴和Y轴是任意的,唯一的限制是它们必须形成正交基础。
This link解释了如何推导矩阵R.
答案 2 :(得分:0)
现在,我遇到了这个问题。我想将点云投影到XY平面,YZ平面和XZ平面。最后,在此页面中找到答案: https://pcl.readthedocs.io/projects/tutorials/en/latest/project_inliers.html?highlight=ModelCoefficients:
在本教程中,我们将学习如何将点投影到参数模型(例如,平面,球体等)上。参数模型通过一组系数给出-在平面情况下,通过其方程式:ax + by + cz + d = 0。 为避免页面丢失,请按以下步骤复制代码:
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected (new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
//We then create the point cloud structure, fill in the respective values, and display the content on screen.
cloud->width = 5;
cloud->height = 1;
cloud->points.resize (cloud->width * cloud->height);
for (auto& point: *cloud)
{
point.x = 1024 * rand () / (RAND_MAX + 1.0f);
point.y = 1024 * rand () / (RAND_MAX + 1.0f);
point.z = 1024 * rand () / (RAND_MAX + 1.0f);
}
std::cerr << "Cloud before projection: " << std::endl;
for (const auto& point: *cloud)
std::cerr << " " << point.x << " "
<< point.y << " "
<< point.z << std::endl;
// Create a set of planar coefficients with X=Y=0,Z=1
//We fill in the ModelCoefficients values. In this case, we use a plane model, with ax+by+cz+d=0, where a=b=d=0, and c=1, or said differently, the X-Y plane.
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
coefficients->values.resize (4);
coefficients->values[0] = coefficients->values[1] = 0;
coefficients->values[2] = 1.0;
coefficients->values[3] = 0;
// Create the filtering object
//We create the ProjectInliers object and use the ModelCoefficients defined above as the model to project onto.
pcl::ProjectInliers<pcl::PointXYZ> proj;
proj.setModelType (pcl::SACMODEL_PLANE);
proj.setInputCloud (cloud);
proj.setModelCoefficients (coefficients);
proj.filter (*cloud_projected);
std::cerr << "Cloud after projection: " << std::endl;
for (const auto& point: *cloud_projected)
std::cerr << " " << point.x << " "
<< point.y << " "
<< point.z << std::endl;
return (0);
}
上面的代码来自PCL网站。