码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • C++ PCL点云局部颜色变换


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

    前言

    这篇博客针对《C++ PCL点云局部颜色变换》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


    运行结果


    文章目录

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

    一、所需工具软件

           1. VS2019, Qt
           2. C++

    二、使用步骤

    代码如下(示例):
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("viewer"));
    pcl::PointCloud<pcl::PointXYZ>::Ptr clicked_points_3d(new pcl::PointCloud<pcl::PointXYZ>);
    int num = 0;
    unsigned char* pointmark;//点云分类标记
    
    
    
    namespace
    {
         #include
         #include
    	void MarkSelectPointIndexToTxt(std::vector<int>& indices, std::string txtfilename)
    	{
    		std::fstream ofs(txtfilename, std::ios::out);
    		if (ofs.is_open())
    		{
    			for (auto& index : indices)
    			{
    				ofs << std::to_string(index) << "\n";
    			}
    
    			ofs.flush();
    			ofs.close();
    			std::cout << "write" << txtfilename << "successfully" << std::endl;
    		}
    
    	}
    
    
    }
    
    
    void main()
    {
    	char path[100];
    	sprintf_s(path, "Airplane_v1.pcd");
    	if (pcl::io::loadPCDFile(path, *cloud))
    	{
    		std::cerr << "ERROR: Cannot open file " << std::endl;
    		return;
    	}
    	pointmark = new unsigned char[cloud->size()];
    	for (size_t i = 0; i < cloud->size(); i++)
    	{
    		pointmark[i] = 0;//初始化点云分类标识,0为未标记点
    	}
    	viewer->addPointCloud<pcl::PointXYZ>(cloud, "point");//添加显示点云
    	clicked_points_3d->width = 0;//初始化点云个数
    
    	std::vector<int> indices;
    	//读尾巴的点
    	//ReadPointIndexFromTxt(indices, "tail.txt");
    	//读翅膀的点
    	ReadPointIndexFromTxt(indices, "head.txt");
    	//添加点云(去掉重复的点)
    	int addcount = 0;//添加点计数
    	for (int i = 0; i < indices.size(); ++i)
    	{
    		if (pointmark[indices[i]] == 0)
    		{
    			clicked_points_3d->points.push_back(cloud->points.at(indices[i]));
    			addcount++;
    			pointmark[indices[i]] = 1;//将点云标记为已圈选状态
    		}
    	}
    	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> red(clicked_points_3d, 255, 0, 0);
    	//每添加一次点云都要取一次别名,不然只能选择一次
    	std::stringstream ss;
    	std::string cloudName;
    	ss << num++;
    	ss >> cloudName;
    	cloudName += "_cloudName";
    	//添加点云,并设置其显示半径
    	viewer->addPointCloud(clicked_points_3d, red, cloudName);
    	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, cloudName);
    	//viewer->registerAreaPickingCallback(pp_callback, (void*)&cloud);
    	while (!viewer->wasStopped())
    	{
    		viewer->spinOnce(100);
    
    	}
    	delete[]pointmark;
    }
    
    
    
    • 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
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    运行结果

    三、在线协助:

    如需安装运行环境或远程调试,见文章底部个人 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

  • 相关阅读:
    VisualSVN initialization failed, For more details see Output window.
    ‘“xxx.exe“‘ 不是内部或外部命令,也不是可运行的程序
    JavaScript(ES6)入门
    Spring Data的Repositories----Query by Example
    数据治理-数据安全-基本概念
    M. My University Is Better Than Yours(思维)
    [免费专栏] Android安全之ZIP文件目录遍历漏洞
    绘制几何图形
    物联网平台建设方案
    jar包不能够直接运行的解决办法
  • 原文地址:https://blog.csdn.net/alicema1111/article/details/133760424
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号