ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qColorimetricSegmenter.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // ##########################################################################
11 // # #
12 // # CLOUDVIEWER PLUGIN: ColorimetricSegmenter #
13 // # #
14 // # This program is free software; you can redistribute it and/or modify #
15 // # it under the terms of the GNU General Public License as published by #
16 // # the Free Software Foundation; version 2 of the License. #
17 // # #
18 // # This program is distributed in the hope that it will be useful, #
19 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
20 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21 // # GNU General Public License for more details. #
22 // # #
23 // # COPYRIGHT: Tri-Thien TRUONG, Ronan COLLIER, Mathieu LETRONE #
24 // # #
25 // ##########################################################################
26 
27 #include "ecvStdPluginInterface.h"
28 
29 // cloudViewer
30 #include <ReferenceCloud.h>
31 
32 // Qt
33 #include <QObject>
34 #include <QtGui>
35 
36 class ccPointCloud;
37 
38 class ColorimetricSegmenter : public QObject, public ccStdPluginInterface {
39  Q_OBJECT
41  Q_PLUGIN_METADATA(IID
42  "ecvcorp.cloudviewer.plugin.ColorimetricSegmenter" FILE
43  "info.json")
44 
45 public:
46  explicit ColorimetricSegmenter(QObject* parent = nullptr);
47  ~ColorimetricSegmenter() override = default;
48 
49  // inherited from ccStdPluginInterface
50  void onNewSelection(const ccHObject::Container& selectedEntities) override;
51  QList<QAction*> getActions() override;
52 
53 private:
54  std::vector<ccPointCloud*> getSelectedPointClouds();
55 
57  void filterRgb();
58 
59  void filterHSV();
60 
61  void filterScalar();
62 
63  void HistogramClustering();
64 
65  void KmeansClustering();
66 
67  bool addPoint(cloudViewer::ReferenceCloud& filteredCloud, unsigned int j);
68 
69  template <typename T>
70  void createClouds(T& dlg,
71  ccPointCloud* cloud,
72  const cloudViewer::ReferenceCloud& filteredCloudInside,
73  const cloudViewer::ReferenceCloud& filteredCloudOutside,
74  QString name);
75 
76  void createCloud(ccPointCloud* cloud,
77  const cloudViewer::ReferenceCloud& referenceCloud,
78  QString name);
79 
81  void filterRgbWithSegmentation();
82 
84  typedef QSharedPointer<cloudViewer::ReferenceCloud> Region;
86  typedef std::vector<Region> RegionSet;
87 
99  static bool RegionGrowing(RegionSet& regions,
100  ccPointCloud* pointCloud,
101  const unsigned TNN,
102  const double TPP,
103  const double TD);
104 
118  static bool RegionMergingAndRefinement(RegionSet& mergedRegions,
119  ccPointCloud* basePointCloud,
120  const RegionSet& regions,
121  const unsigned TNN,
122  const double TRR,
123  const double TD,
124  const unsigned Min);
125 
126 private: // members
127  QAction* m_action_filterRgb;
128  // QAction* m_action_filterRgbWithSegmentation;
129  QAction* m_action_filterHSV;
130  QAction* m_action_filterScalar;
131  QAction* m_action_histogramClustering;
132  QAction* m_action_kMeansClustering;
133 
135  bool m_addPointError;
136 };
std::string name
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
Standard ECV plugin interface.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Standard ECV plugin interface.
A very simple point cloud (no point duplication)
static const unsigned Min
static const double TPP
static const unsigned TNN
static const double TD
static const double TRR