• C++ PCL点云曲率分割颜色标识


    程序示例精选
    C++ PCL点云曲率分割颜色标识
    如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

    前言

    这篇博客针对《C++ PCL点云曲率分割颜色标识》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


    运行结果


    文章目录

    一、所需工具软件
    二、使用步骤
           1. 主要代码
           2. 运行结果
    三、在线协助

    一、所需工具软件

           1. VS2019
           2. C++

    二、使用步骤

    代码如下(示例):
    
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace std;
    
    int main(int argc, char** argv)
    {
    
    	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    	pcl::io::loadPCDFile<pcl::PointXYZ>("20191009_Cloud222 - Cloud2-1 las2pcd-move-scanline.pcd", *cloud); //读取点云
    	cout << "Loaded " << cloud->points.size() << " points." << endl;//显示读取点云的个数
    	// 计算点云的法线
    	pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
    	n.setInputCloud(cloud);
    	//设置邻域点搜索方式
    	pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
    	n.setSearchMethod(tree);
    	//设置KD树搜索半径
    	 //n.setRadiusSearch (0.02);
    	n.setKSearch(25);
    	//定义一个新的点云储存含有法线的值
    	pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
    	//计算出来法线的值
    	n.compute(*normals);
    	// 建立主曲率计算
    	pcl::PrincipalCurvaturesEstimation<pcl::PointXYZ, pcl::Normal, pcl::PrincipalCurvatures> p;
    
    	// 计算主曲率
    	pcl::PointCloud<pcl::PrincipalCurvatures>::Ptr pri(new pcl::PointCloud<pcl::PrincipalCurvatures>());
    	cout << "output points.size: " << pri->points.size() << endl;
    
    	pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_b(new pcl::PointCloud<pcl::PointXYZRGB>);
    	cloud_b->points.resize(cloud->size());
    
    	for (int i = 0; i < cloud->points.size(); i++)//所有点赋予灰色
    	{
    		cloud_b->points[i].x = cloud->points[i].x;
    		cloud_b->points[i].y = cloud->points[i].y;
    		cloud_b->points[i].z = cloud->points[i].z;
    		/*cout << "曲率:" << pri->points[i].pc1 << ";"
    			<< pri->points[i].pc2 << ";"
    			<< (pri->points[i].pc1 + pri->points[i].pc2) / 2 << ";"
    			<< pri->points[i].pc1 * pri->points[i].pc2<//逐点显示计算的最大曲率,最小曲率,平均曲率,高斯曲率
    	}
    
    	for (int i = 0; i < pri->points.size(); i++)//
    	{
    		//if (pri->points[i].pc1>0.01)//最大曲率
    		//if (pri->points[i].pc2>0.01)//最小曲率
    		//if ((pri->points[i].pc1 + pri->points[i].pc2)/2>0.01)//平均曲率
    	}
    	//显示第0个点的最大曲率、最小曲率、平均曲率、高斯曲率、法向量计算出来的曲率。目的:就是想看看法向量这个数据结构里的曲率到底计算的是哪个曲率。结果:好像哪个都不是
    	cout << "曲率:" << pri->points[0].pc1 << ";"
    		<< pri->points[0].pc2 << ";"
    		<< (pri->points[0].pc1 + pri->points[0].pc2) / 2 << ";"
    		<< pri->points[0].pc1 * pri->points[0].pc2 << ";"
    		<< normals->points[0].curvature << endl;
    
    	pcl::visualization::CloudViewer viewer("Viewer");
    	viewer.showCloud(cloud_b);
    
    	pcl::io::savePLYFile<pcl::PointXYZRGB>("20191009_Cloud222 - Cloud2-1 las2pcd-move-scanline-angle2.ply", *cloud_b);
    
    
    	getchar();
    	return 0;
    }
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    运行结果

    三、在线协助:

    如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!

    1)远程安装运行环境,代码调试
    2)Visual Studio, Qt, C++, Python编程语言入门指导
    3)界面美化
    4)软件制作

    当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
    个人博客主页https://blog.csdn.net/alicema1111?type=blog
    博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

    博主推荐:
    Python人脸识别考勤打卡系统:
    https://blog.csdn.net/alicema1111/article/details/133434445
    Python果树水果识别https://blog.csdn.net/alicema1111/article/details/130862842
    Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
    Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
    Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
    Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
    Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445

  • 相关阅读:
    微擎模块 志汇同城微圈小程序10.9.5开源版
    【菜菜研科研小BUG记录】【Latex写作方面1】不定期更新
    “漫丝路”主题餐饮空间设计
    期货开户公司想恶意滑点是做不到的
    Redis 集群搭建--Linux 开发三主三从
    【已解决】启动SSH服务报“could not load host key”错误
    弹性数据库连接池探活策略调研(三)——DBCP
    音视频 ffplay命令播放媒体
    SMT贴片制造:专业、现代、智能的未来之选
    What is Fan-out
  • 原文地址:https://blog.csdn.net/alicema1111/article/details/133760960