ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
CloudSamplingTools.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 // Local
11 #include "CVToolbox.h"
12 #include "DgmOctree.h"
13 
14 namespace cloudViewer {
15 
16 class GenericIndexedCloud;
17 class GenericIndexedCloudPersist;
18 class GenericIndexedMesh;
19 class GenericProgressCallback;
20 class PointCloud;
21 class ReferenceCloud;
22 class ReferenceCloudPersist;
23 
26 public:
29  enum RESAMPLING_CELL_METHOD { CELL_CENTER, CELL_GRAVITY_CENTER };
30 
33  enum SUBSAMPLING_CELL_METHOD { RANDOM_POINT, NEAREST_POINT_TO_CELL_CENTER };
34 
36 
49  static PointCloud* resampleCloudWithOctreeAtLevel(
51  unsigned char octreeLevel,
52  RESAMPLING_CELL_METHOD resamplingMethod,
53  GenericProgressCallback* progressCb = nullptr,
54  DgmOctree* inputOctree = nullptr);
55 
57 
70  static GenericIndexedCloud* resampleCloudWithOctree(
72  int newNumberOfPoints,
73  RESAMPLING_CELL_METHOD resamplingMethod,
74  GenericProgressCallback* progressCb = nullptr,
75  DgmOctree* inputOctree = nullptr);
76 
78 
91  static ReferenceCloud* subsampleCloudWithOctreeAtLevel(
93  unsigned char octreeLevel,
94  SUBSAMPLING_CELL_METHOD subsamplingMethod,
95  GenericProgressCallback* progressCb = nullptr,
96  DgmOctree* inputOctree = nullptr);
97 
99 
112  static ReferenceCloud* subsampleCloudWithOctree(
114  int newNumberOfPoints,
115  SUBSAMPLING_CELL_METHOD subsamplingMethod,
116  GenericProgressCallback* progressCb = nullptr,
117  DgmOctree* inputOctree = nullptr);
118 
120 
129  static ReferenceCloud* subsampleCloudRandomly(
131  unsigned newNumberOfPoints,
132  GenericProgressCallback* progressCb = nullptr);
133 
135  unsigned every_k_points);
136 
140  explicit SFModulationParams(bool state = false)
141  : enabled(state), a(0.0), b(1.0) {}
142 
144  bool enabled;
146  double a;
148  double b;
149  };
150 
152 
164  static ReferenceCloud* resampleCloudSpatially(
166  PointCoordinateType minDistance,
167  const SFModulationParams& modParams,
168  DgmOctree* octree = nullptr,
169  GenericProgressCallback* progressCb = nullptr);
170 
172 
185  static ReferenceCloud* sorFilter(
187  int knn = 6,
188  double nSigma = 1.0,
189  DgmOctree* octree = nullptr,
190  GenericProgressCallback* progressCb = nullptr);
191 
193 
208  static ReferenceCloud* noiseFilter(
210  PointCoordinateType kernelRadius,
211  double nSigma,
212  bool removeIsolatedPoints = false,
213  bool useKnn = false,
214  int knn = 6,
215  bool useAbsoluteError = true,
216  double absoluteError = 0.0,
217  DgmOctree* octree = nullptr,
218  GenericProgressCallback* progressCb = nullptr);
219 
220 protected:
223 
233  static bool resampleCellAtLevel(const DgmOctree::octreeCell& cell,
234  void** additionalParameters,
235  NormalizedProgress* nProgress = nullptr);
236 
238 
248  static bool subsampleCellAtLevel(const DgmOctree::octreeCell& cell,
249  void** additionalParameters,
250  NormalizedProgress* nProgress = nullptr);
251 
253 
259  static bool applyNoiseFilterAtLevel(
260  const DgmOctree::octreeCell& cell,
261  void** additionalParameters,
262  NormalizedProgress* nProgress = nullptr);
263 
265 
271  static bool applySORFilterAtLevel(const DgmOctree::octreeCell& cell,
272  void** additionalParameters,
273  NormalizedProgress* nProgress = nullptr);
274 };
275 
276 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
Several point cloud resampling algorithms (octree-based, random, etc.)
The octree structure used throughout the library.
Definition: DgmOctree.h:39
A generic 3D point cloud with index-based and presistent access to points.
A generic 3D point cloud with index-based point access.
A very simple point cloud (no point duplication)
::ccPointCloud PointCloud
Definition: PointCloud.h:19
void UniformDownSample(benchmark::State &state, const core::Device &device, size_t k)
Definition: PointCloud.cpp:94
Generic file read and write utility for python interface.
cloudViewer::NormalizedProgress * nProgress
cloudViewer::DgmOctree * octree
unsigned char octreeLevel
Parameters for the scalar-field based modulation of a parameter.
SFModulationParams(bool state=false)
Default constructor.
bool enabled
Whether the modulation is enabled or not.
double b
Modulation scheme: y = a.sf + b.
double a
Modulation scheme: y = a.sf + b.
Octree cell descriptor.
Definition: DgmOctree.h:354