热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

PCL学习笔记(45)——超体分割SupervoxelClustering

论文地址pdf下载地址源码#include#include#include

论文地址pdf下载地址

源码

#include
#include
#include
#include
#include
#include // Types
typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud PointCloudT;
typedef pcl::PointNormal PointNT;
typedef pcl::PointCloud PointNCloudT;
typedef pcl::PointXYZL PointLT;
typedef pcl::PointCloud PointLCloudT;void addSupervoxelConnectionsToViewer (PointT &supervoxel_center,PointCloudT &adjacent_supervoxel_centers,std::string supervoxel_name,boost::shared_ptr & viewer);int main (int argc, char ** argv)
{if (argc <2){pcl::console::print_error ("Syntax is: %s \n ""--NT Dsables the single cloud transform \n""-v \n-s \n""-c \n-z \n""-n \n", argv[0]);return (1);}PointCloudT::Ptr cloud &#61; boost::make_shared ();pcl::console::print_highlight ("Loading point cloud...\n");if (pcl::io::loadPCDFile (argv[1], *cloud)){pcl::console::print_error ("Error loading cloud file!\n");return (1);}cout<<"point size of input: "<size()< super (voxel_resolution, seed_resolution);if (disable_transform)super.setUseSingleCameraTransform (false);super.setInputCloud (cloud);super.setColorImportance (color_importance);super.setSpatialImportance (spatial_importance);super.setNormalImportance (normal_importance);std::map ::Ptr > supervoxel_clusters;//该单映射容器以标签为键值存储所有超体素pcl::console::print_highlight ("Extracting supervoxels!\n");super.extract (supervoxel_clusters);pcl::console::print_info ("Found %d supervoxels\n", supervoxel_clusters.size ());boost::shared_ptr viewer (new pcl::visualization::PCLVisualizer ("点云库PCL学习教程第二版-超体素分割"));viewer->setBackgroundColor (1,1,1);PointCloudT::Ptr voxel_centroid_cloud &#61; super.getVoxelCentroidCloud ();cout<<"voxel centroids: "<size()<addPointCloud(voxel_centroid_cloud,"voxel centroids");pcl::io::savePCDFile("voxel_centroids.pcd",*voxel_centroid_cloud);viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,4, "voxel centroids");viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.5, "voxel centroids");}PointLCloudT::Ptr labeled_voxel_cloud &#61; super.getLabeledVoxelCloud ();if(1){//超体素分割结果显示与保存pcl::io::savePCDFile("labeled_voxels.pcd",*labeled_voxel_cloud);viewer->addPointCloud (labeled_voxel_cloud, "labeled voxels");cout<<"labeled voxels: "<size()<setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,3, "labeled voxels");// viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_OPACITY,0.8, "labeled voxels");}PointNCloudT::Ptr sv_normal_cloud &#61; super.makeSupervoxelNormalCloud (supervoxel_clusters);//if(0)//超体素对应的法线特征可视化viewer->addPointCloudNormals (sv_normal_cloud,1,0.05f, "supervoxel_normals");pcl::console::print_highlight ("Getting supervoxel adjacency\n");std::multimap supervoxel_adjacency;super.getSupervoxelAdjacency (supervoxel_adjacency);cout<<"size of supervoxel_adjacency: "<::iterator label_itr &#61; supervoxel_adjacency.begin ();for ( ; label_itr !&#61; supervoxel_adjacency.end (); ){//获取标签值uint32_t supervoxel_label &#61; label_itr->first;//根据标签索引到该超体素pcl::Supervoxel::Ptr supervoxel &#61; supervoxel_clusters.at (supervoxel_label);//遍历该超体素相邻超体素并以其相邻超体素中心为点集构造点云&#xff0c;用于后续可视化&#xff0c;这里的相邻超体素在多重映射容器中具有相同的键值PointCloudT adjacent_supervoxel_centers;std::multimap::iterator adjacent_itr &#61; supervoxel_adjacency.equal_range (supervoxel_label).first;for ( ; adjacent_itr!&#61;supervoxel_adjacency.equal_range (supervoxel_label).second; &#43;&#43;adjacent_itr){pcl::Supervoxel::Ptr neighbor_supervoxel &#61; supervoxel_clusters.at (adjacent_itr->second);adjacent_supervoxel_centers.push_back (neighbor_supervoxel->centroid_);}//std::stringstream ss;ss <<"supervoxel_" <centroid_, adjacent_supervoxel_centers, ss.str (), viewer);//使迭代器指向下一个标签。label_itr &#61; supervoxel_adjacency.upper_bound (supervoxel_label);}while (!viewer->wasStopped ()){viewer->spinOnce();}return (0);
}void addSupervoxelConnectionsToViewer (PointT &supervoxel_center,PointCloudT &adjacent_supervoxel_centers,std::string supervoxel_name,boost::shared_ptr & viewer)
{int i&#61;0;//Iterate through all adjacent points, and add a center point to adjacent point pairPointCloudT::iterator adjacent_itr &#61; adjacent_supervoxel_centers.begin ();for ( ; adjacent_itr !&#61; adjacent_supervoxel_centers.end (); &#43;&#43;adjacent_itr){std::stringstream ss;ss<addLine(supervoxel_center,*adjacent_itr,ss.str());viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,3,ss.str());viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,0,255,0,ss.str());ss<addSphere(supervoxel_center,0.008,0,0,255,ss.str());viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_SHADING,pcl::visualization::PCL_VISUALIZER_SHADING_GOURAUD,ss.str());//viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY,0.9,ss.str());i&#43;&#43;;}}

在这里插入图片描述


推荐阅读
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文介绍了机器学习手册中关于日期和时区操作的重要性以及其在实际应用中的作用。文章以一个故事为背景,描述了学童们面对老先生的教导时的反应,以及上官如在这个过程中的表现。同时,文章也提到了顾慎为对上官如的恨意以及他们之间的矛盾源于早年的结局。最后,文章强调了日期和时区操作在机器学习中的重要性,并指出了其在实际应用中的作用和意义。 ... [详细]
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • 使用eclipse创建一个Java项目的步骤
    本文介绍了使用eclipse创建一个Java项目的步骤,包括启动eclipse、选择New Project命令、在对话框中输入项目名称等。同时还介绍了Java Settings对话框中的一些选项,以及如何修改Java程序的输出目录。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • C# 7.0 新特性:基于Tuple的“多”返回值方法
    本文介绍了C# 7.0中基于Tuple的“多”返回值方法的使用。通过对C# 6.0及更早版本的做法进行回顾,提出了问题:如何使一个方法可返回多个返回值。然后详细介绍了C# 7.0中使用Tuple的写法,并给出了示例代码。最后,总结了该新特性的优点。 ... [详细]
  • Google Play推出全新的应用内评价API,帮助开发者获取更多优质用户反馈。用户每天在Google Play上发表数百万条评论,这有助于开发者了解用户喜好和改进需求。开发者可以选择在适当的时间请求用户撰写评论,以获得全面而有用的反馈。全新应用内评价功能让用户无需返回应用详情页面即可发表评论,提升用户体验。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 3.223.28周学习总结中的贪心作业收获及困惑
    本文是对3.223.28周学习总结中的贪心作业进行总结,作者在解题过程中参考了他人的代码,但前提是要先理解题目并有解题思路。作者分享了自己在贪心作业中的收获,同时提到了一道让他困惑的题目,即input details部分引发的疑惑。 ... [详细]
  • 【shell】网络处理:判断IP是否在网段、两个ip是否同网段、IP地址范围、网段包含关系
    本文介绍了使用shell脚本判断IP是否在同一网段、判断IP地址是否在某个范围内、计算IP地址范围、判断网段之间的包含关系的方法和原理。通过对IP和掩码进行与计算,可以判断两个IP是否在同一网段。同时,还提供了一段用于验证IP地址的正则表达式和判断特殊IP地址的方法。 ... [详细]
  • 本文介绍了在C#中SByte类型的GetHashCode方法,该方法用于获取当前SByte实例的HashCode。给出了该方法的语法和返回值,并提供了一个示例程序演示了该方法的使用。 ... [详细]
author-avatar
z漫步云端j
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有