点云ISS+3DSC+SAC-IA+icp代码
时间: 2023-09-08 13:10:26 浏览: 184
以下是点云ISS、3DSC、SAC-IA、ICP的代码示例:
1. ISS 特征提取
```c++
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
pcl::ISSKeypoint3D<pcl::PointXYZ, pcl::PointXYZ> iss_detector;
iss_detector.setSearchMethod(tree);
iss_detector.setSalientRadius(6 * resolution);
iss_detector.setNonMaxRadius(4 * resolution);
iss_detector.setThreshold21(0.975);
iss_detector.setThreshold32(0.975);
iss_detector.setMinNeighbors(5);
iss_detector.setInputCloud(cloud);
iss_detector.compute(*keypoints);
```
2. 3DSC 特征描述
```c++
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::ShapeContext1980>::Ptr descriptors(new pcl::PointCloud<pcl::ShapeContext1980>);
pcl::ShapeContext3DEstimation<pcl::PointXYZ, pcl::ShapeContext1980> desc_est;
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
desc_est.setInputCloud(keypoints);
desc_est.setInputNormals(normals);
desc_est.setSearchMethod(tree);
desc_est.setRadiusSearch(4 * resolution);
desc_est.compute(*descriptors);
```
3. SAC-IA 平面拟合
```c++
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
pcl::SACSegmentation<pcl::PointXYZ> seg;
seg.setOptimizeCoefficients(true);
seg.setModelType(pcl::SACMODEL_PLANE);
seg.setMethodType(pcl::SAC_RANSAC);
seg.setMaxIterations(1000);
seg.setDistanceThreshold(0.01);
seg.setInputCloud(cloud);
seg.segment(*inliers, *coefficients);
```
4. ICP 点云配准
```c++
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr aligned(new pcl::PointCloud<pcl::PointXYZ>);
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
icp.setInputSource(cloud1);
icp.setInputTarget(cloud2);
icp.setMaxCorrespondenceDistance(0.05);
icp.setMaximumIterations(50);
icp.setTransformationEpsilon(1e-8);
icp.setEuclideanFitnessEpsilon(1);
icp.align(*aligned);
```
阅读全文