PCL学习(三) SAC-IA 估记object pose
SAC-IA是基于RANSAC算法的对齐算法
通过降采样提高法向计算、FPFH特征的计算
最后通过SAC-IA计算得到对齐的旋转和平移
#include <Eigen/Core>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/common/time.h>
#include <pcl/console/print.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/features/fpfh_omp.h>
#include <pcl/filters/filter.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/io/pcd_io.h>
#include <pcl/registration/icp.h>
#include <pcl/registration/sample_consensus_prerejective.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
// Types
typedef pcl::PointNormal PointNT;
typedef pcl::PointCloud<PointNT> PointCloudT;
typedef pcl::FPFHSignature33 FeatureT;
typedef pcl::FPFHEstimationOMP<PointNT, PointNT, FeatureT> FeatureEstimationT;
typedef pcl::PointCloud<FeatureT> FeatureCloudT;
typedef pcl::visualization::PointCloudColorHandlerCustom<PointNT> ColorHandlerT;//handle the param of the align in the txt to save the fucking time of complie
int parseConfigFile(const std::string &filepath,char *objFile,char *sceFile,float *downLeaf
);// Align a rigid object to a scene with clutter and occlusions
int main(int argc, char **argv)
{// Point cloudsPointCloudT::Ptr object(new PointCloudT);PointCloudT::Ptr object_aligned(new PointCloudT);PointCloudT::Ptr scene(new PointCloudT);FeatureCloudT::Ptr object_features(new FeatureCloudT);FeatureCloudT::Ptr scene_features(new FeatureCloudT);// Get input object and scene/*if (argc != 3){pcl::console::print_error("Syntax is: %s object.pcd scene.pcd\n", argv[0]);return (1);}*//*std::string paramFilePath = "data/param.txt";char *obj_filepath = { '\0' };char *sce_filepath = { '\0' };float *downsample_leaf = nullptr;parseConfigFile(paramFilePath,obj_filepath,sce_filepath,downsample_leaf);*/// Load object and scenepcl::console::print_highlight("Loading point clouds...\n");if (pcl::io::loadPCDFile<PointNT>("data/obj_seg.pcd", *object) < 0 ||//"data/obj_seg.pcd"pcl::io::loadPCDFile<PointNT>("data/sce_seg.pcd", *scene) < 0) //"data/sce_seg.pcd"{pcl::console::print_error("Error loading object/scene file!\n");return (1);}// Downsamplepcl::console::print_highlight("Downsampling...\n");pcl::VoxelGrid<PointNT> grid;const float leaf = 0.08f;//0.005f == resolution of 5mmgrid.setLeafSize(leaf, leaf, leaf);grid.setInputCloud(object);grid.filter(*object);grid.setInputCloud(scene);grid.filter(*scene);// Estimate normals for scenepcl::console::print_highlight("Estimating scene normals...\n");pcl::NormalEstimationOMP<PointNT, PointNT> nest;nest.setRadiusSearch(0.01);nest.setInputCloud(scene);nest.compute(*scene);// Estimate featurespcl::console::print_highlight("Estimating features...\n");FeatureEstimationT fest;fest.setRadiusSearch(0.025);fest.setInputCloud(object);fest.setInputNormals(object);fest.compute(*object_features);fest.setInputCloud(scene);fest.setInputNormals(scene);fest.compute(*scene_features);// Perform alignmentpcl::console::print_highlight("Starting alignment...\n");pcl::SampleConsensusPrerejective<PointNT, PointNT, FeatureT> align;align.setInputSource(object);align.setSourceFeatures(object_features);align.setInputTarget(scene);align.setTargetFeatures(scene_features);align.setMaximumIterations(100000); // Number of RANSAC iterations 50000align.setNumberOfSamples(3); // Number of points to sample for generating/prerejecting a posealign.setCorrespondenceRandomness(5); // Number of nearest features to usealign.setSimilarityThreshold(0.9f); // Polygonal edge length similarity thresholdalign.setMaxCorrespondenceDistance(2.5f * leaf); // Inlier thresholdalign.setInlierFraction(0.25f); // Required inlier fraction for accepting a pose hypothesis{pcl::ScopeTime t("Alignment");align.align(*object_aligned);}if (align.hasConverged()){// Print resultsprintf("\n");Eigen::Matrix4f transformation = align.getFinalTransformation();pcl::console::print_info(" | %6.3f %6.3f %6.3f | \n", transformation(0, 0), transformation(0, 1), transformation(0, 2));pcl::console::print_info("R = | %6.3f %6.3f %6.3f | \n", transformation(1, 0), transformation(1, 1), transformation(1, 2));pcl::console::print_info(" | %6.3f %6.3f %6.3f | \n", transformation(2, 0), transformation(2, 1), transformation(2, 2));pcl::console::print_info("\n");pcl::console::print_info("t = < %0.3f, %0.3f, %0.3f >\n", transformation(0, 3), transformation(1, 3), transformation(2, 3));pcl::console::print_info("\n");pcl::console::print_info("Inliers: %i/%i\n", align.getInliers().size(), object->size());// Show alignmentpcl::visualization::PCLVisualizer visu("Alignment");visu.addPointCloud(scene, ColorHandlerT(scene, 0.0, 255.0, 0.0), "scene");visu.addPointCloud(object_aligned, ColorHandlerT(object_aligned, 0.0, 0.0, 255.0), "object_aligned");visu.spin();system("PAUSE");}else{pcl::console::print_error("Alignment failed!\n");system("PAUSE");return (1);}return (0);
}int parseConfigFile(const std::string &filepath,char *objFile,char *sceFile,float *downLeaf
)
{// open the configuration fileFILE *file = fopen(filepath.c_str(), "r");//FILE *stream;//testif (!file){fprintf(stderr, "Cannot parse configuration file \"%s\".\n",filepath.c_str());exit(1);}//read parameterschar buf[256];while (fscanf(file, "%s", buf) != EOF) {switch (buf[0]) {case '#':fgets(buf, sizeof(buf), file);break;case'o':fgets(buf, sizeof(buf), file);memcpy(objFile, buf + 1, strlen(buf) - 2);//printf("%s", objFile);break;case's':fgets(buf, sizeof(buf), file);memcpy(sceFile, buf + 1, strlen(buf) - 2);break;case'l':fscanf(file, "%f", downLeaf);}}return 0;}
对齐前的点云数据(采集于两帧kinect的扫描深度图)
对齐后的结果
对齐的旋转和平移,以及对齐速度
转载于:https://www.cnblogs.com/BambooEatPanda/p/8184895.html
PCL学习(三) SAC-IA 估记object pose相关推荐
- pcl 学习论文阅读(Towards 3D Object Maps for Autonomous Household Robots)
Towards 3D Object Maps for Autonomous Household Robots,2007 室内环境的3D地图构建 摘要 描述了室内环境下的绘图系统,如何获取室内目标模型 ...
- GDR-Net: Geometry-Guided Direct Regression Network for Monocular 6D Object Pose Estimati
转载请注明作者和出处: http://blog.csdn.net/john_bh/ paper 地址:GDR-Net: Geometry-Guided Direct Regression Networ ...
- 点云入门笔记(三):PCL基础以及PCL学习指南
1.PCL介绍: PCL(Point Cloud Library)是在吸收了前人点云相关研究基础上建立起来的大型跨平台开源C++编程库,它实现了大量点云相关的通用算法和高效数据结构,涉及到点云获取.滤 ...
- PCL学习笔记(二):PCL官方教程学习
PCL学习笔记(二):PCL官方教程学习 PCD文件制作 Features 表面法线提取 Keypoints 提取NARF关键点 KdTree Range Image How to create a ...
- 深度学习三巨头Hinton,Bengio,LeCunn共摘本年度ACM图灵奖(ACM A.M. Turing Award)
ACM官网消息:https://awards.acm.org/about/2018-turing 众所周知的深度学习三巨头: Yoshua Bengio, Geoffrey Hinton, Yann ...
- Docker学习三:Docker 数据管理
前言 本次学习来自于datawhale组队学习: 教程地址为: https://github.com/datawhalechina/team-learning-program/tree/master/ ...
- 昨日种种已得奖,那深度学习三巨头今天在忙什么?
上周,AI圈最大的事情,没有之一,就是图灵奖,终于终于,终于颁给了深度学习三巨头. 关于Geoffrey Hinton和他的两位学生Yoshua Bengio.Yann LeCun的故事,在消息出来后 ...
- 论文笔记(三):PoseCNN: A Convolutional Neural Network for 6D Object Pose Estimation in Cluttered Scenes
PoseCNN: A Convolutional Neural Network for 6D Object Pose Estimation in Cluttered Scenes 文章概括 摘要 1. ...
- 第三周 目标检测(Object detection)
第三周 目标检测(Object detection) 文章目录 第三周 目标检测(Object detection) 3.1 目标定位(Object localization) 3.2 特征点检测(L ...
最新文章
- 产品线的长度宽度深度_LED照明经销商该如何规划自己的产品线
- 论文 | 图像和谐化公开数据集:让前景和背景更“般配”
- 2017杭州_考驾照笔记
- Java数据结构和算法:数组、单链表、双链表
- java B2B2C Springcloud电子商城系统-通过消息队列传输zipkin日志
- 让人迷茫的三十岁,从专业技能、行业知识和软实力的人才三角谈起
- 新手学习python(四)字符串方法
- python __builtins__ frozenset类 (27)
- codevs 3160 最长公共子串
- dcp9020cdn硒鼓!错误_打印机硒鼓错误是什么意思?故障解决【详解】
- 计算机组成原理——硬布线控制器设计(1)
- 微商引流的六种有效方法
- 从此甩掉光驱 U盘安装系统最详攻略(转自腾讯数码)
- 哈希算法----猜词游戏
- 手机APP如何远程控制PLC
- 【探花交友】阿里云OSS、百度人脸识别
- 我们的flowable改造(8)-----BPMN模型
- 深度学习模型DNN部署到安卓(移动)设备上——pytorch->onnx->ncnn->Android
- CGTrader年度压轴大赛——“CG游戏角色竞赛”赛果揭晓!!!
- 华为诺亚方舟实验室招聘自动驾驶NeRF算法实习生
热门文章
- 028-Dell服务器做Raid
- MySQL 5.7系列之sys schema(2)
- visual studio installer 卸载时不能删除安装目录问题
- CSS的class、id、css文件名的常用命名规则
- [Example of Sklearn] - Example
- Java线程--扩展
- app-v 4.6 management server部署(一)
- css transition改动透明,使用CSS transition和animation改变渐变状态的实现方法
- mysql8和php7不能连接_php无法连接mysql8.x
- redis 备份导出rdb_Redis持久化知识点—RDB+AOF ,你了解多少