PCL笔记

icp.getFinalTransformation()的结果

在ICP默认代码中,是源点云配目标点云,求取的变换矩阵是源点云——>目标点云的变换矩阵,

官方的源点云是cloud_icp,目标点云是cloud_in,ICP找的是cloud_icp->cloud_in的变换;然而,输入的点云只有cloud_in;cloud_icp是通过已知的变换得到的,如以下代码;
即:cloud_icp=transformation_matrix *cloud_in(矩阵左乘);

pcl::PointCloud和pcl::PointCloud::Ptr类型的转换

加了ptr的是指针类型,两者可以互相转换
一般常用pcl::PointCloud::Ptr因为kdtreeoctree类中的setInputCloud()函数只支持pcl::PointCloud::Ptr类型
1.PointCloud::Ptr—>PointCloud

pcl::PointCloud<pcl::PointXYZ> cloud;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
cloud=*cloud_ptr;

2.PointCloud—>PointCloud::Ptr

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ> cloud;
cloud_ptr=cloud.makeShared();

example:

1.
pcl::PointCloud<pcl::PointXYZ> cloudA;
pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution);  
octree.setInputCloud(cloudA.makeShared());

2.
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudA(new pcl::PointCloud<pcl::PointXYZ>);
pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution); 
octree.setInputCloud(cloudA);

pcl::transformPointCloud

在PCL中,pcl::transformPointCloud执行的是左乘变换。这意味着变换矩阵被应用于点云的每个点,这可以表示为:

transformed_point = transformation_matrix * original_point

需要注意的是,PCL中的变换矩阵采用齐次坐标表示,因此矩阵的最后一行应该是[0 0 0 1]

猜你喜欢

转载自blog.csdn.net/qq_43200940/article/details/127764906
pcl
今日推荐