CloudCompare中手动点云分割功能ccGraphicalSegmentationTool,

点击应用按钮后将现有的点云分成segmented和remaining两个点云,

//停用点云分割功能
void MainWindow::deactivateSegmentationMode(bool state)

是通过ccPointCloud的可视选择集来实现的。其中用到了点云的swap需要参考!

  1. //创建新的点云,可视的选择集
  2. ccGenericPointCloud* ccPointCloud::createNewCloudFromVisibilitySelection(bool removeSelectedPoints)
  3. {
  4. if (!isVisibilityTableInstantiated())
  5. {
  6. ccLog::Error(QString("[Cloud %1] Visibility table not instantiated!").arg(getName()));
  7. return 0;
  8. }
  9.  
  10. //we create a new cloud with the "visible" points
  11. ccPointCloud* result = 0;
  12. {
  13. //we create a temporary entity with the visible points only
  14. CCLib::ReferenceCloud* rc = getTheVisiblePoints();
  15. if (!rc)
  16. {
  17. //a warning message has already been issued by getTheVisiblePoints!
  18. //ccLog::Warning("[ccPointCloud::createNewCloudFromVisibilitySelection] An error occurred during points selection!");
  19. return 0;
  20. }
  21. assert(rc->size() != 0);
  22.  
  23. //convert selection to cloud
  24. result = partialClone(rc);
  25.  
  26. //don't need this one anymore
  27. delete rc;
  28. rc = 0;
  29. }
  30.  
  31. if (!result)
  32. {
  33. ccLog::Warning("[ccPointCloud::createNewCloudFromVisibilitySelection] An error occurred during segmentation!");
  34. return 0;
  35. }
  36.  
  37. result->setName(getName()+QString(".segmented"));//切割出来的点云
  38.  
  39. //shall the visible points be erased from this cloud?
  40. if (removeSelectedPoints && !isLocked())
  41. {
  42. //we drop the octree before modifying this cloud's contents
  43. deleteOctree();
  44. clearLOD();
  45.  
  46. unsigned count = size();
  47.  
  48. //we have to take care of scan grids first
  49. {
  50. //we need a map between old and new indexes
  51. std::vector<int> newIndexMap(size(), -1);
  52. {
  53. unsigned newIndex = 0;
  54. for (unsigned i=0; i<count; ++i)
  55. {
  56. if (m_pointsVisibility->getValue(i) != POINT_VISIBLE)
  57. newIndexMap[i] = newIndex++;
  58. }
  59. }
  60.  
  61. //then update the indexes
  62. UpdateGridIndexes(newIndexMap, m_grids);
  63.  
  64. //and reset the invalid (empty) ones
  65. //(DGM: we don't erase them as they may still be useful?)
  66. for (size_t i=0; i<m_grids.size(); ++i)
  67. {
  68. Grid::Shared& scanGrid = m_grids[i];
  69. if (scanGrid->validCount == 0)
  70. {
  71. scanGrid->indexes.clear();
  72. }
  73. }
  74. }
  75.  
  76. //we remove all visible points
  77. unsigned lastPoint = 0;
  78. for (unsigned i=0; i<count; ++i)
  79. {
  80. //i持续增长,而lastPoint遇到==POINT_VISIBLE则跳过,起到迁移的效果
  81. if (m_pointsVisibility->getValue(i) != POINT_VISIBLE)
  82. {
  83. if (i != lastPoint)
  84. swapPoints(lastPoint,i);
  85. ++lastPoint;
  86. }
  87. }
  88.  
  89. //TODO: handle associated meshes
  90.  
  91. resize(lastPoint);
  92.  
  93. refreshBB(); //calls notifyGeometryUpdate + releaseVBOs
  94. }
  95.  
  96. return result;
  97. }

  调用的方法getTheVisiblePoints()

  1. CCLib::ReferenceCloud* ccGenericPointCloud::getTheVisiblePoints() const
  2. {
  3. unsigned count = size();
  4. assert(count == m_pointsVisibility->currentSize());
  5.  
  6. if (!m_pointsVisibility || m_pointsVisibility->currentSize() != count)
  7. {
  8. ccLog::Warning("[ccGenericPointCloud::getTheVisiblePoints] No visibility table instantiated!");
  9. return 0;
  10. }
  11.  
  12. //count the number of points to copy
  13. unsigned pointCount = 0;
  14. {
  15. for (unsigned i=0; i<count; ++i)
  16. if (m_pointsVisibility->getValue(i) == POINT_VISIBLE)
  17. ++pointCount;
  18. }
  19.  
  20. if (pointCount == 0)
  21. {
  22. ccLog::Warning("[ccGenericPointCloud::getTheVisiblePoints] No point in selection");
  23. return 0;
  24. }
  25.  
  26. //we create an entity with the 'visible' vertices only
  27. CCLib::ReferenceCloud* rc = new CCLib::ReferenceCloud(const_cast<ccGenericPointCloud*>(this));
  28. if (rc->reserve(pointCount))
  29. {
  30. for (unsigned i=0; i<count; ++i)
  31. if (m_pointsVisibility->getValue(i) == POINT_VISIBLE)
  32. rc->addPointIndex(i); //can't fail (see above)
  33. }
  34. else
  35. {
  36. delete rc;
  37. rc = 0;
  38. ccLog::Error("[ccGenericPointCloud::getTheVisiblePoints] Not enough memory!");
  39. }
  40.  
  41. return rc;
  42. }

  

[CC]手动点云分割的更多相关文章

  1. 基于传统方法点云分割以及PCL中分割模块

      之前在微信公众号中更新了以下几个章节 1,如何学习PCL以及一些基础的知识 2,PCL中IO口以及common模块的介绍 3,PCL中常用的两种数据结构KDtree以及Octree树的介绍    ...

  2. PCL—低层次视觉—点云分割(基于凹凸性)

    1.图像分割的两条思路 场景分割时机器视觉中的重要任务,尤其对家庭机器人而言,优秀的场景分割算法是实现复杂功能的基础.但是大家搞了几十年也还没搞定——不是我说的,是接下来要介绍的这篇论文说的.图像分割 ...

  3. PCL点云分割(1)

    点云分割是根据空间,几何和纹理等特征对点云进行划分,使得同一划分内的点云拥有相似的特征,点云的有效分割往往是许多应用的前提,例如逆向工作,CAD领域对零件的不同扫描表面进行分割,然后才能更好的进行空洞 ...

  4. PCL—点云分割(基于凹凸性) 低层次点云处理

    博客转载自:http://www.cnblogs.com/ironstark/p/5027269.html 1.图像分割的两条思路 场景分割时机器视觉中的重要任务,尤其对家庭机器人而言,优秀的场景分割 ...

  5. PCL—低层次视觉—点云分割(基于形态学)

    1.航空测量与点云的形态学 航空测量是对地形地貌进行测量的一种高效手段.生成地形三维形貌一直是地球学,测量学的研究重点.但对于城市,森林,等独特地形来说,航空测量会受到影响.因为土地表面的树,地面上的 ...

  6. PCL—低层次视觉—点云分割(超体聚类)

    1.超体聚类——一种来自图像的分割方法 超体(supervoxel)是一种集合,集合的元素是“体”.与体素滤波器中的体类似,其本质是一个个的小方块.与之前提到的所有分割手段不同,超体聚类的目的并不是分 ...

  7. PCL—低层次视觉—点云分割(最小割算法)

    1.点云分割的精度 在之前的两个章节里介绍了基于采样一致的点云分割和基于临近搜索的点云分割算法.基于采样一致的点云分割算法显然是意识流的,它只能割出大概的点云(可能是杯子的一部分,但杯把儿肯定没分割出 ...

  8. PCL—低层次视觉—点云分割(RanSaC)

    点云分割 点云分割可谓点云处理的精髓,也是三维图像相对二维图像最大优势的体现.不过多插一句,自Niloy J Mitra教授的Global contrast based salient region ...

  9. segMatch:基于3D点云分割的回环检测

    该论文的地址是:https://arxiv.org/pdf/1609.07720.pdf segmatch是一个提供车辆的回环检测的技术,使用提取和匹配分割的三维激光点云技术.分割的例子可以在下面的图 ...

随机推荐

  1. 【leetcode】Find Minimum in Rotated Sorted Array I&&II

    题目概述: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 ...

  2. MEF Parts Sample

    namespace Microshaoft.MEF.Contracts { using System; public delegate void ExceptionEventHandler<TS ...

  3. UWP 禁止Pivot swip 手势

    以前想要禁止内置的手势动作,看了一下网上是设置 IsLocked="True". 但是拿到UWP上来,靠,设置了之后header只显示当前的那个header.这样的设计真是丑爆了. ...

  4. Appirater -- app中提示用户为app评价的提示框

    Appirater是一段你可以嵌入自己工程中的代码,在用户使用应用一段时间后会自动弹出提示用户进行评分. 使用Appirater方面,你可以简单把源代码嵌入你的app工程中,并把以下代码添加至它的委托 ...

  5. 解决Eclipse左键无法查看maven第三方包的源代码,多图亲测可用【转】

    Debug进不了的原因及解决办法: 一.ctrl+左键点击没有找到你的源码 1.先设置maven 2.通过maven下Jar包源码 选中总包目录下的pom.xml-->右键-->Run A ...

  6. 分布式缓存技术memcached学习(五)—— memcached java客户端的使用

    Memcached的客户端简介 我们已经知道,memcached是一套分布式的缓存系统,memcached的服务端只是缓存数据的地方,并不能实现分布式,而memcached的客户端才是实现分布式的地方 ...

  7. 2016 Multi-University Training Contest 6

    5/12 2016 Multi-University Training Contest 6 官方题解 打表找规律/推公式 A A Boring Question(BH) 题意: ,意思就是在[0,n] ...

  8. Leetcode Unique Paths II

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  9. Qt里获取目录的一个另类方法

    如果有一个文件的全路径文件名, 想获取它的路径的话, qt里我没找到比较好的办法, 都是cleanPath后, 再用QString的find, left这种函数来处理. 今天又在搞这种问题的时候, 看 ...

  10. Python2 下 Unicode 的一个小bug

    关于Python的编码问题已经是老生常谈了,此处主要是介绍一个罕见的问题,也算是Python2的一个bug了(Python3不会有此问题). 在有时候我们去爬取网页或者调用一些第三方库获取文本的时候, ...