PCL学习Day7

提取关键点
  • 计算分辨率‘
#include <pcl/io/pcd_io.h>
#include <pcl/search/kdtree.h>

// This function by Tommaso Cavallari and Federico Tombari, taken from the tutorial
// http://pointclouds.org/documentation/tutorials/correspondence_grouping.php
double computeCloudResolution(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr& cloud)
{
	double resolution = 0.0;
	int numberOfPoints = 0;
	int nres;
	std::vector<int> indices(2);
	std::vector<float> squaredDistances(2);
	pcl::search::KdTree<pcl::PointXYZ> tree;
	tree.setInputCloud(cloud);

	for (size_t i = 0; i < cloud->size(); ++i)
	{
		if (!std::isfinite((*cloud)[i].x))
			continue;

		// Considering the second neighbor since the first is the point itself.
		nres = tree.nearestKSearch(i, 2, indices, squaredDistances);
		if (nres == 2)
		{
			resolution += sqrt(squaredDistances[1]);
			++numberOfPoints;
		}
	}
	if (numberOfPoints != 0)
		resolution /= numberOfPoints;

	return resolution;
}
#pragma once
  • 计算关键点并且显示
#include<pcl/io/pcd_io.h>
#include <pcl/point_types.h>
// 包含相关头文件
#include<pcl/keypoints/iss_3d.h>
#include<pcl/visualization/pcl_visualizer.h>
#include "resolution.h"// 计算模型的分辨率

using namespace std;
typedef pcl::PointXYZ PointT;

int main() {
	// 读取点云
	pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>);
	pcl::io::loadPCDFile("rabbit.pcd", *cloud);
	std::cout << "original cloud size : " << cloud->size() << std::endl;
	double resolution = computeCloudResolution(cloud);// 计算模型分辨率
	cout << "模型分辨率为" << resolution << endl;

	pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());

	pcl::ISSKeypoint3D<PointT, PointT> iss_dector;
	pcl::ISSKeypoint3D<PointT, PointT> 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.setNumberOfThreads(4);
	iss_detector.setInputCloud(cloud);
	pcl::PointCloud<PointT>::Ptr keys(new pcl::PointCloud<PointT>);
	iss_detector.compute(*keys);
	pcl::io::savePCDFile("keypoints.pcd", *keys, true);
	std::cout << "key points size : " << keys->size() << std::endl;
	//显示
	pcl::visualization::PCLVisualizer viewer;
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> fildColor(cloud, 255, 222, 173);//设置点云颜色
	viewer.addPointCloud<pcl::PointXYZ>(cloud, fildColor, "orginal cloud");
	viewer.addPointCloud<pcl::PointXYZ>(keys, "keyPoints");
	viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 5, "keyPoints");//设置点的大小
	viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 255, 0, 0, "keyPoints");.//设置点的颜色
	viewer.spin();
	system("pause");
	return 0;
}

在这里插入图片描述

参考链接:https://github.com/MNewBie/PCL-Notes/blob/master/chapter2.md

https://zhuanlan.zhihu.com/p/268524083

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: CSDN PCL学习教程是一个非常值得推荐的学习资源。PCL(Point Cloud Library)是一个开源的机器人视觉库,用于处理和分析点云数据。 CSDN PCL学习教程的内容丰富全面,适合初学者和有一定基础的人士。教程以通俗易懂的语言介绍了PCL库的基本知识和应用,包括点云数据的读取、滤波、特征提取、配准、分割等等。其中还包括了一些实际的案例,通过动手实践可以更好地理解和运用PCL库。 CSDN PCL学习教程的优点是它提供了详细的步骤和示例代码,使学习者能够快速入门和上手。教程中也附有一些常见问题的解答和错误排查的方法,方便遇到困难时进行参考和解决。 此外,CSDN是一个知名的IT技术社区,拥有众多活跃的技术博客和论坛。在学习教程过程中,学习者还能够参与讨论和交流,获取更多的帮助和指导。 总的来说,CSDN PCL学习教程是一个实用、可靠的学习资源,对于想要学习和应用PCL库的人来说是一个不错的选择。它提供了全面的学习内容和实例,能够满足不同层次的学习需求,并能够帮助学习者快速掌握PCL库的使用。 ### 回答2: CSDN PCL学习教程是一个针对计算机视觉领域的开源库Point Cloud Library(PCL)的学习资源。PCL是一个强大的开源点云处理框架,可以用于点云数据的处理、配准、分割、特征提取等多种任务。 该教程提供了丰富的学习内容和实践案例。首先,教程介绍了PCL的基础知识,包括点云数据的表示方式、常用的滤波方法等。接着,教程详细介绍了PCL的各种功能模块,如滤波器、配准、特征描述子等,通过实例演示了它们的使用方法和效果。 此外,教程也提供了一些高级主题的学习资料,如深度学习与点云处理的结合、三维重建等。这些内容可以帮助学习者进一步深入PCL的应用领域。 通过学习CSDN PCL学习教程,学习者能够掌握PCL的基本原理和使用方法,了解点云数据处理的常用技巧。通过实践案例的学习学习者能够将PCL应用到具体的项目中,并具备进行自主研究和开发的能力。 总之,CSDN PCL学习教程是一个全面而丰富的学习资源,对于想要进一步学习和应用点云处理的计算机视觉领域从业者和研究者来说是一个不错的选择。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值