大点云不要用pcl::registration::CorrespondenceRejectorSampleConsensus<pcl::PointXYZ>去除

试了很多次,最后的转换矩阵为单位矩阵

可以用pcl::registration::TransformationEstimationSVD,这样是 ok的,转换后接近于目标矩阵


 pcl::registration::TransformationEstimationSVD<pcl::PointXYZ, pcl::PointXYZ> trans_east;
 Eigen::Matrix4f transformation_matrix;
 trans_east.estimateRigidTransformation(*cloud_siftOutput1, *cloud_siftOutput2, *correspondences, transformation_matrix);
 pcl::transformPointCloud(*cloud_sampled1, *cloud_in_filtered_Raw, transformation_matrix);


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
:优化方法: 1. 增加注释,使得代码更易于理解。 2. 将代码分成多个函数,使得每个函数专门做一件事,利于维护和修改。 3. 减少冗余代码,将重复的代码封装成一个函数并重复利用,使代码更简洁。 4. 可以考虑并行化操作,提高代码执行效率。 修改后的代码如下: // 读取点云数据 pcl::PointCloud<pcl::PointXYZ>::Ptr loadPointCloud(const std::string& fileName) { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::io::loadPCDFile<pcl::PointXYz>(fileName, *cloud); return cloud; } // 直通滤波器 pcl::PointCloud<pcl::PointXYZ>::Ptr passThroughFilter(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) { pcl::PassThrough<pcl::PointxYZ> pass; pass.setInputCloud(cloud); pass.setFilterFieldName("x"); pass.setEilterLimits(0.0, 1.0); pcl::PointCloud<pcl::PointXz>::Ptr filtered(new pcl::PointCloud<pcl::PointXYz>); pass.filter(*filtered); return filtered; } // 提取滤波器 pcl::PointCloud<pcl::PointXYZ>::Ptr extractFilter(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, const std::vector<int>& removedIndices) { pcl::ExtractIndices<pcl::PointxYZ> extract; extract.setInputCloud(cloud) ; extract.setIndices(removedIndices); extract.setNegative(true); pcl::PointCloud<pcl::PointXYZ>::Ptr extracted(new pcl::PointCloud<pcl::PointXYz>); extract.filter(*extracted); return extracted; } // 保存滤波后的点云数据 void savePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, const std::string& fileName) { pcl::io::savePCDFile<pcl::PointXYZ>(fileName, *cloud); } // 主函数 int main(int argc, char** argv) { // 读取点云数据 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = loadPointCloud("input cloud.pcd"); // 应用直通滤波器 pcl::PointCloud<pcl::PointXYZ>::Ptr filteredCloud = passThroughFilter(cloud); // 应用提取滤波器 std::vector<int> removedIndices = pass.getRemovedIndices(); pcl::PointCloud<pcl::PointXYZ>::Ptr extractedCloud = extractFilter(cloud, removedIndices); // 保存滤波后的点云数据 savePointCloud(filteredCloud, "filtered cloud.pcd"); savePointCloud(extractedCloud, "extracted cloud.pcd"); return 0; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值