将点云的坐标转换为点云库中的另一个坐标,从而使地平面成为X-O-Y平面?
Transform point cloud's coordinates to another coordinates in Point Cloud Library, which makes the ground plane as the X-O-Y plane?
我有一个来自kinect融合的点云,并使用点云库成功地分割了地平面(a x+by+c*z+d=0)(我在pcl::ModelCoefficients中得到了a,b,c,d)。现在我需要将笛卡尔坐标转换为新的笛卡尔坐标,使地平面成为 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
我成功解决了这个问题!
我无法打开指向您的 API 的链接,但猜测您可以使用简单的转换来转换您的平面:
- 您应该添加到所有点向量 {a * d, b * d, c * d} -将您的点移动到平面 ax + x + cz = 0
- 然后你应该找到围绕轴的旋转矩阵 [{a, b, c} 十字{0, 0, 1}]在角度 [{a, b, c} 点 {0, 0, 1}] 上并变换您的此矩阵的点数http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix-在这里您可以看到如何从轴和角度找到旋转矩阵
此函数需要相机姿势,这是一个 4x4 矩阵,形式为
| R t |
| 0 1 |
这里,R 是 3x3 旋转矩阵,t 是 3x1 平移向量,0 - 是 1x3 的零向量,1 是单位(标量)。
您应该以这样的方式设计此矩阵,即新坐标系中的 Z 轴将与平面的法线矢量共线。新的 X 轴和 Y 轴是任意的,唯一的限制是它们必须形成正交基。
此链接说明如何派生矩阵 R。
现在,我遇到了这个问题。我想将点云投影到 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网站。
- QGraphicsPolygonItem在拖动时未更新QPolygonF坐标
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 在 cpp 中的平面缓冲区中序列化对象
- 将平面阵列重塑为复杂的特征类型
- OpenGL 4.3 错误地将第 4 个纹理坐标映射到与第 3 个纹理坐标相同的位置
- 比较两个节点坐标的最佳方法是什么?
- 在 OpenGL 中将笛卡尔世界坐标转换为球面局部坐标
- CGAL:在浏览平面地图时使用类型"标记"
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 如何在C++中获取坐标?
- 如何将 x.y 坐标的值存储在不同的数组中
- 平面缓冲区可以利用向量中的 0 吗?还是其他小波比哈尔变换更好?
- 计算世界坐标中z_far平面的顶点
- 使用提示用户输入笛卡尔平面中某些点的x-y坐标(浮点类型)的函数
- 如何在XYZ播放器平面中找出前向坐标
- 将点云的坐标转换为点云库中的另一个坐标,从而使地平面成为X-O-Y平面?
- 用坐标搜索笛卡尔平面上的几何图形
- OpenCV立体视觉3D坐标到2D相机平面投影不同于将2D点三角化到3D
- 查找/重新映射OpenGL ES坐标平面的边界