ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qRANSAC_SD.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 #include "ecvStdPluginInterface.h"
11 
14 
18 class qRansacSD : public QObject, public ccStdPluginInterface {
19  Q_OBJECT
21  Q_PLUGIN_METADATA(IID "ecvcorp.cloudviewer.plugin.qRansacSD" FILE
22  "../info.json")
23 
24 public:
25  enum RANSAC_PRIMITIVE_TYPES {
26  RPT_PLANE = 0,
27  RPT_SPHERE = 1,
28  RPT_CYLINDER = 2,
29  RPT_CONE = 3,
30  RPT_TORUS = 4,
31  };
32 
33  struct RansacParams {
34  float epsilon; // distance threshold
35  float bitmapEpsilon; // bitmap resolution
36  unsigned supportPoints; // this is the minimal numer of points required
37  // for a primitive
38  float maxNormalDev_deg; // maximal normal deviation from ideal shape
39  // (in degrees)
40  float probability; // probability that no better candidate was
41  // overlooked during sampling
42  bool randomColor; // should the resulting detected shapes sub point
43  // cloud be colored randomly
44  bool primEnabled[5]; // RANSAC_PRIMITIVE_TYPES
45  float minRadius;
46  float maxRadius;
47  RansacParams()
48  : epsilon(0.005f),
49  bitmapEpsilon(0.01f),
50  supportPoints(500),
51  maxNormalDev_deg(25.0f),
52  probability(0.01f),
53  randomColor(true),
54  minRadius(0.0000001f),
55  maxRadius(1000000.0f) {
56  primEnabled[RPT_PLANE] = true;
57  primEnabled[RPT_SPHERE] = true;
58  primEnabled[RPT_CYLINDER] = true;
59  primEnabled[RPT_CONE] = false;
60  primEnabled[RPT_TORUS] = false;
61  };
62 
63  RansacParams(float scale)
64  : epsilon(0.005f * scale),
65  bitmapEpsilon(0.01f * scale),
66  supportPoints(500),
67  maxNormalDev_deg(25.0f),
68  probability(0.01f),
69  randomColor(true),
70  minRadius(0.0000001f),
71  maxRadius(1000000.0f) {
72  primEnabled[RPT_PLANE] = true;
73  primEnabled[RPT_SPHERE] = true;
74  primEnabled[RPT_CYLINDER] = true;
75  primEnabled[RPT_CONE] = false;
76  primEnabled[RPT_TORUS] = false;
77  };
78  };
79 
81  explicit qRansacSD(QObject* parent = nullptr);
82 
83  // inherited from ccStdPluginInterface
84  virtual QList<QAction*> getActions() override;
85  virtual void registerCommands(ccCommandLineInterface* cmd) override;
86  virtual void onNewSelection(
87  const ccHObject::Container& selectedEntities) override;
88 
89  static ccHObject* executeRANSAC(ccPointCloud* ccPC,
90  const RansacParams& params,
91  bool silent = false);
92 protected slots:
93 
95  void doAction();
96 
97 protected:
99  QAction* m_action;
100 };
#define slots
cmdLineReadable * params[]
Command line interface.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
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.
QAction * m_action
Associated action.
Definition: qRANSAC_SD.h:99
void doAction()
Slot called when associated ation is triggered.
Definition: qRANSAC_SD.cpp:121