ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
PointCloud.cpp
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 
9 
10 #include <benchmark/benchmark.h>
11 
18 
19 namespace cloudViewer {
20 namespace t {
21 namespace geometry {
22 
23 void FromLegacyPointCloud(benchmark::State& state, const core::Device& device) {
24  ccPointCloud legacy_pcd;
25  unsigned int num_points = 1000000; // 1M
26  legacy_pcd.reserveThePointsTable(num_points);
27  legacy_pcd.reserveTheRGBTable();
28  legacy_pcd.resize(num_points);
29 
30  // Warm up.
32  legacy_pcd, core::Float32, device);
33  (void)pcd;
34 
35  for (auto _ : state) {
37  legacy_pcd, core::Float32, device);
39  }
40 }
41 
42 void ToLegacyPointCloud(benchmark::State& state, const core::Device& device) {
43  int64_t num_points = 1000000; // 1M
44  PointCloud pcd(device);
45  pcd.SetPointPositions(core::Tensor({num_points, 3}, core::Float32, device));
46  pcd.SetPointColors(core::Tensor({num_points, 3}, core::Float32, device));
47 
48  // Warm up.
49  ccPointCloud legacy_pcd = pcd.ToLegacy();
50  (void)legacy_pcd;
51 
52  for (auto _ : state) {
53  ccPointCloud legacy_pcd = pcd.ToLegacy();
55  }
56 }
57 
59 static const std::string path = pointcloud_ply.GetPath();
60 
61 void LegacyVoxelDownSample(benchmark::State& state, float voxel_size) {
63  for (auto _ : state) {
64  pcd->VoxelDownSample(voxel_size);
65  }
66 }
67 
68 void VoxelDownSample(benchmark::State& state,
69  const core::Device& device,
70  float voxel_size,
71  const std::string& reduction) {
73  // t::io::CreatePointCloudFromFile lacks support of remove_inf_points and
74  // remove_nan_points
75  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
76  pcd = pcd.To(device);
77 
78  // Warm up.
79  pcd.VoxelDownSample(voxel_size, reduction);
80 
81  for (auto _ : state) {
82  pcd.VoxelDownSample(voxel_size, reduction);
84  }
85 }
86 
87 void LegacyUniformDownSample(benchmark::State& state, size_t k) {
89  for (auto _ : state) {
90  pcd->UniformDownSample(k);
91  }
92 }
93 
94 void UniformDownSample(benchmark::State& state,
95  const core::Device& device,
96  size_t k) {
98  // t::io::CreatePointCloudFromFile lacks support of remove_inf_points and
99  // remove_nan_points
100  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
101  pcd = pcd.To(device);
102 
103  // Warm up.
104  pcd.UniformDownSample(k);
105 
106  for (auto _ : state) {
107  pcd.UniformDownSample(k);
108  core::cuda::Synchronize(device);
109  }
110 }
111 
112 void LegacyTransform(benchmark::State& state, const int no_use) {
113  ccPointCloud pcd;
114  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
115 
116  Eigen::Matrix4d transformation = Eigen::Matrix4d::Identity();
117  transformation.block<3, 1>(0, 3) = Eigen::Vector3d(1, 2, 3);
118 
119  // Warm Up.
120  ccPointCloud pcd_transformed = pcd.Transform(transformation);
121 
122  for (auto _ : state) {
123  pcd_transformed = pcd.Transform(transformation);
124  }
125 }
126 
127 void Transform(benchmark::State& state, const core::Device& device) {
128  PointCloud pcd;
129  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
130  pcd = pcd.To(device);
131 
132  core::Dtype dtype = pcd.GetPointPositions().GetDtype();
133  core::Tensor transformation = core::Tensor::Init<double>({{1, 0, 0, 1.0},
134  {0, 1, 0, 2.0},
135  {0, 0, 1, 3.0},
136  {0, 0, 0, 1}},
137  device)
138  .To(dtype);
139 
140  // Warm Up.
141  PointCloud pcd_transformed = pcd.Transform(transformation);
142 
143  for (auto _ : state) {
144  pcd_transformed = pcd.Transform(transformation);
145  core::cuda::Synchronize(device);
146  }
147 }
148 
149 void SelectByIndex(benchmark::State& state,
150  bool remove_duplicates,
151  const core::Device& device) {
152  PointCloud pcd;
153  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
154  pcd = pcd.To(device);
155 
156  const int64_t num_points = pcd.GetPointPositions().GetLength();
157  core::Tensor indices =
158  core::Tensor::Arange(0, num_points, 1, core::Int64, device);
159 
160  // Warm Up.
161  PointCloud pcd_selected =
162  pcd.SelectByIndex(indices, false, remove_duplicates);
163 
164  for (auto _ : state) {
165  pcd_selected = pcd.SelectByIndex(indices);
166  core::cuda::Synchronize(device);
167  }
168 }
169 
170 void LegacySelectByIndex(benchmark::State& state, const int no_use) {
171  ccPointCloud pcd;
172  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
173 
174  const size_t num_points = pcd.size();
175  std::vector<size_t> indices(num_points);
176  std::iota(indices.begin(), indices.end(), 0);
177 
178  // Warm Up.
179  ccPointCloud pcd_selected = *pcd.SelectByIndex(indices);
180 
181  for (auto _ : state) {
182  pcd_selected = *pcd.SelectByIndex(indices);
183  }
184 }
185 
186 void EstimateNormals(benchmark::State& state,
187  const core::Device& device,
188  const core::Dtype& dtype,
189  const double voxel_size,
190  const utility::optional<int> max_nn,
191  const utility::optional<double> radius) {
193  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
194 
195  pcd = pcd.To(device).VoxelDownSample(voxel_size);
196  pcd.SetPointPositions(pcd.GetPointPositions().To(dtype));
197  if (pcd.HasPointNormals()) {
198  pcd.RemovePointAttr("normals");
199  }
200 
201  // Warm up.
202  pcd.EstimateNormals(max_nn, radius);
203  for (auto _ : state) {
204  pcd.EstimateNormals(max_nn, radius);
205  }
206 }
207 
209  benchmark::State& state,
210  const double voxel_size,
211  const cloudViewer::geometry::KDTreeSearchParam& search_param) {
212  ccPointCloud pcd;
213  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
214 
215  auto pcd_down = pcd.VoxelDownSample(voxel_size);
216 
217  // Warm up.
218  pcd_down->EstimateNormals(search_param, true);
219 
220  for (auto _ : state) {
221  pcd_down->EstimateNormals(search_param, true);
222  }
223 }
224 
225 void RemoveRadiusOutliers(benchmark::State& state,
226  const core::Device& device,
227  const int nb_points,
228  const double search_radius) {
230  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
231 
232  pcd = pcd.To(device).VoxelDownSample(0.01);
233 
234  // Warm up.
235  pcd.RemoveRadiusOutliers(nb_points, search_radius);
236  for (auto _ : state) {
237  pcd.RemoveRadiusOutliers(nb_points, search_radius);
238  }
239 }
240 
241 void RemoveStatisticalOutliers(benchmark::State& state,
242  const core::Device& device,
243  const int nb_neighbors) {
245  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
246 
247  pcd = pcd.To(device).VoxelDownSample(0.01);
248 
249  // Warm up.
250  pcd.RemoveStatisticalOutliers(nb_neighbors, 1.0);
251  for (auto _ : state) {
252  pcd.RemoveStatisticalOutliers(nb_neighbors, 1.0);
253  }
254 }
255 
256 void ComputeBoundaryPoints(benchmark::State& state,
257  const core::Device& device,
258  const core::Dtype& dtype,
259  const int max_nn,
260  const double radius) {
262  const std::string path = pointcloud_ply.GetPointCloudPath();
264  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
265  pcd = pcd.To(device);
266  pcd.SetPointPositions(pcd.GetPointPositions().To(dtype));
267  pcd.SetPointNormals(pcd.GetPointNormals().To(dtype));
268 
269  // Warm up.
270  pcd.ComputeBoundaryPoints(radius, max_nn);
271 
272  for (auto _ : state) {
273  pcd.ComputeBoundaryPoints(radius, max_nn);
274  }
275 }
276 
277 void LegacyRemoveStatisticalOutliers(benchmark::State& state,
278  const int nb_neighbors) {
279  ccPointCloud pcd;
280  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
281 
282  auto pcd_down = pcd.VoxelDownSample(0.01);
283 
284  // Warm up.
285  pcd_down->RemoveStatisticalOutliers(nb_neighbors, 1.0);
286 
287  for (auto _ : state) {
288  pcd_down->RemoveStatisticalOutliers(nb_neighbors, 1.0);
289  }
290 }
291 
292 void LegacyRemoveRadiusOutliers(benchmark::State& state,
293  const int nb_points,
294  const double search_radius) {
295  ccPointCloud pcd;
296  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
297 
298  auto pcd_down = pcd.VoxelDownSample(0.01);
299 
300  // Warm up.
301  pcd_down->RemoveRadiusOutliers(nb_points, search_radius);
302 
303  for (auto _ : state) {
304  pcd_down->RemoveRadiusOutliers(nb_points, search_radius);
305  }
306 }
307 
308 void CropByAxisAlignedBox(benchmark::State& state, const core::Device& device) {
310  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
311 
312  pcd = pcd.To(device);
314  core::Tensor::Init<float>({0, 0, 0}, device),
315  core::Tensor::Init<float>({1, 1, 1}, device));
316 
317  // Warm up.
318  pcd.Crop(box);
319 
320  for (auto _ : state) {
321  pcd.Crop(box);
322  }
323 }
324 
325 void CropByOrientedBox(benchmark::State& state, const core::Device& device) {
327  t::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
328 
329  pcd = pcd.To(device);
331  core::Tensor::Init<float>({0, 0, 0}, device),
332  core::Tensor::Eye(3, core::Float32, device),
333  core::Tensor::Init<float>({1, 1, 1}, device));
334 
335  // Warm up.
336  pcd.Crop(box);
337 
338  for (auto _ : state) {
339  pcd.Crop(box);
340  }
341 }
342 
343 void LegacyCropByAxisAlignedBox(benchmark::State& state, const int no_use) {
344  ccPointCloud pcd;
345  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
346 
347  cloudViewer::geometry::AxisAlignedBoundingBox box(Eigen::Vector3d(0, 0, 0),
348  Eigen::Vector3d(1, 1, 1));
349 
350  // Warm up.
351  pcd.Crop(box);
352 
353  for (auto _ : state) {
354  pcd.Crop(box);
355  }
356 }
357 
358 void LegacyCropByOrientedBox(benchmark::State& state, const int no_use) {
359  ccPointCloud pcd;
360  cloudViewer::io::ReadPointCloud(path, pcd, {"auto", false, false, false});
361 
362  cloudViewer::geometry::OrientedBoundingBox box(Eigen::Vector3d(0, 0, 0),
363  Eigen::Matrix3d::Identity(),
364  Eigen::Vector3d(1, 1, 1));
365 
366  // Warm up.
367  pcd.Crop(box);
368 
369  for (auto _ : state) {
370  pcd.Crop(box);
371  }
372 }
373 
375  ->Unit(benchmark::kMillisecond);
376 
378  ->Unit(benchmark::kMillisecond);
379 
380 #ifdef BUILD_CUDA_MODULE
382  ->Unit(benchmark::kMillisecond);
383 
385  ->Unit(benchmark::kMillisecond);
386 #endif
387 
388 #define ENUM_VOXELSIZE(DEVICE, REDUCTION) \
389  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_01, DEVICE, 0.01, \
390  REDUCTION) \
391  ->Unit(benchmark::kMillisecond); \
392  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_02, DEVICE, 0.08, \
393  REDUCTION) \
394  ->Unit(benchmark::kMillisecond); \
395  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_04, DEVICE, 0.04, \
396  REDUCTION) \
397  ->Unit(benchmark::kMillisecond); \
398  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_08, DEVICE, 0.08, \
399  REDUCTION) \
400  ->Unit(benchmark::kMillisecond); \
401  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_16, DEVICE, 0.16, \
402  REDUCTION) \
403  ->Unit(benchmark::kMillisecond); \
404  BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_32, DEVICE, 0.32, \
405  REDUCTION) \
406  ->Unit(benchmark::kMillisecond);
407 
408 const std::string kReductionMean = "mean";
409 #ifdef BUILD_CUDA_MODULE
410 #define ENUM_VOXELDOWNSAMPLE_REDUCTION() \
411  ENUM_VOXELSIZE(core::Device("CPU:0"), kReductionMean) \
412  ENUM_VOXELSIZE(core::Device("CUDA:0"), kReductionMean)
413 #else
414 #define ENUM_VOXELDOWNSAMPLE_REDUCTION() \
415  ENUM_VOXELSIZE(core::Device("CPU:0"), kReductionMean)
416 #endif
417 
418 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_01, 0.01)
419  ->Unit(benchmark::kMillisecond);
420 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_02, 0.02)
421  ->Unit(benchmark::kMillisecond);
422 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_04, 0.04)
423  ->Unit(benchmark::kMillisecond);
424 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_08, 0.08)
425  ->Unit(benchmark::kMillisecond);
426 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_16, 0.16)
427  ->Unit(benchmark::kMillisecond);
428 BENCHMARK_CAPTURE(LegacyVoxelDownSample, Legacy_0_32, 0.32)
429  ->Unit(benchmark::kMillisecond);
431 
433  ->Unit(benchmark::kMillisecond);
435  ->Unit(benchmark::kMillisecond);
437  ->Unit(benchmark::kMillisecond);
438 BENCHMARK_CAPTURE(UniformDownSample, CPU_2, core::Device("CPU:0"), 2)
439  ->Unit(benchmark::kMillisecond);
440 BENCHMARK_CAPTURE(UniformDownSample, CPU_5, core::Device("CPU:0"), 5)
441  ->Unit(benchmark::kMillisecond);
442 BENCHMARK_CAPTURE(UniformDownSample, CPU_10, core::Device("CPU:0"), 10)
443  ->Unit(benchmark::kMillisecond);
444 
445 BENCHMARK_CAPTURE(Transform, CPU, core::Device("CPU:0"))
446  ->Unit(benchmark::kMillisecond);
447 
448 BENCHMARK_CAPTURE(SelectByIndex, CPU, false, core::Device("CPU:0"))
449  ->Unit(benchmark::kMillisecond);
450 
452  CPU(remove duplicates),
453  true,
454  core::Device("CPU:0"))
455  ->Unit(benchmark::kMillisecond);
456 
457 #ifdef BUILD_CUDA_MODULE
458 BENCHMARK_CAPTURE(UniformDownSample, CUDA_2, core::Device("CUDA:0"), 2)
459  ->Unit(benchmark::kMillisecond);
460 BENCHMARK_CAPTURE(UniformDownSample, CUDA_5, core::Device("CUDA:0"), 5)
461  ->Unit(benchmark::kMillisecond);
462 BENCHMARK_CAPTURE(UniformDownSample, CUDA_10, core::Device("CUDA:0"), 10)
463  ->Unit(benchmark::kMillisecond);
464 BENCHMARK_CAPTURE(Transform, CUDA, core::Device("CUDA:0"))
465  ->Unit(benchmark::kMillisecond);
466 BENCHMARK_CAPTURE(SelectByIndex, CUDA, false, core::Device("CUDA:0"))
467  ->Unit(benchmark::kMillisecond);
469  CUDA(remove duplicates),
470  true,
471  core::Device("CUDA:0"))
472  ->Unit(benchmark::kMillisecond);
473 #endif
474 
476  CPU F32 Hybrid[0.02 | 30 | 0.06],
477  core::Device("CPU:0"),
479  0.02,
480  30,
481  0.06)
482  ->Unit(benchmark::kMillisecond);
484  CPU F64 Hybrid[0.02 | 30 | 0.06],
485  core::Device("CPU:0"),
487  0.02,
488  30,
489  0.06)
490  ->Unit(benchmark::kMillisecond);
492  CPU F32 KNN[0.02 | 30],
493  core::Device("CPU:0"),
495  0.02,
496  30,
498  ->Unit(benchmark::kMillisecond);
500  CPU F64 KNN[0.02 | 30],
501  core::Device("CPU:0"),
503  0.02,
504  30,
506  ->Unit(benchmark::kMillisecond);
508  CPU F32 Radius[0.02 | 0.06],
509  core::Device("CPU:0"),
511  0.02,
513  0.06)
514  ->Unit(benchmark::kMillisecond);
516  CPU F64 Radius[0.02 | 0.06],
517  core::Device("CPU:0"),
519  0.02,
521  0.06)
522  ->Unit(benchmark::kMillisecond);
523 #ifdef BUILD_CUDA_MODULE
525  CUDA F32 Hybrid[0.02 | 30 | 0.06],
526  core::Device("CUDA:0"),
528  0.02,
529  30,
530  0.06)
531  ->Unit(benchmark::kMillisecond);
533  CUDA F64 Hybrid[0.02 | 30 | 0.06],
534  core::Device("CUDA:0"),
536  0.02,
537  30,
538  0.06)
539  ->Unit(benchmark::kMillisecond);
541  CUDA F32 KNN[0.02 | 30],
542  core::Device("CUDA:0"),
544  0.02,
545  30,
547  ->Unit(benchmark::kMillisecond);
549  CUDA F64 KNN[0.02 | 30],
550  core::Device("CUDA:0"),
552  0.02,
553  30,
555  ->Unit(benchmark::kMillisecond);
557  CUDA F32 Radius[0.02 | 0.06],
558  core::Device("CUDA:0"),
560  0.02,
562  0.06)
563  ->Unit(benchmark::kMillisecond);
565  CUDA F64 Radius[0.02 | 0.06],
566  core::Device("CUDA:0"),
568  0.02,
570  0.06)
571  ->Unit(benchmark::kMillisecond);
572 #endif
573 
574 BENCHMARK_CAPTURE(LegacyTransform, CPU, 1)->Unit(benchmark::kMillisecond);
575 BENCHMARK_CAPTURE(LegacySelectByIndex, CPU, 1)->Unit(benchmark::kMillisecond);
576 
578  Legacy Hybrid[0.02 | 30 | 0.06],
579  0.02,
581  ->Unit(benchmark::kMillisecond);
582 
584  Legacy KNN[0.02 | 30],
585  0.02,
587  ->Unit(benchmark::kMillisecond);
588 
590  Legacy Radius[0.02 | 0.06],
591  0.02,
593  ->Unit(benchmark::kMillisecond);
594 
596  RemoveRadiusOutliers, CPU[50 | 0.05], core::Device("CPU:0"), 50, 0.03)
597  ->Unit(benchmark::kMillisecond);
599  ->Unit(benchmark::kMillisecond);
601  ->Unit(benchmark::kMillisecond);
603  ->Unit(benchmark::kMillisecond);
605  CPU Float32,
606  core::Device("CPU:0"),
608  30,
609  0.02)
610  ->Unit(benchmark::kMillisecond);
612  CPU Float64,
613  core::Device("CPU:0"),
615  30,
616  0.02)
617  ->Unit(benchmark::kMillisecond);
618 #ifdef BUILD_CUDA_MODULE
620  RemoveRadiusOutliers, CUDA[50 | 0.05], core::Device("CUDA:0"), 50, 0.03)
621  ->Unit(benchmark::kMillisecond);
623  ->Unit(benchmark::kMillisecond);
625  ->Unit(benchmark::kMillisecond);
627  CUDA[30],
628  core::Device("CUDA:0"),
629  30)
630  ->Unit(benchmark::kMillisecond);
632  CUDA Float32,
633  core::Device("CUDA:0"),
635  30,
636  0.02)
637  ->Unit(benchmark::kMillisecond);
639  CUDA Float64,
640  core::Device("CUDA:0"),
642  30,
643  0.02)
644  ->Unit(benchmark::kMillisecond);
645 #endif
646 
647 BENCHMARK_CAPTURE(LegacyRemoveRadiusOutliers, Legacy[50 | 0.05], 50, 0.03)
648  ->Unit(benchmark::kMillisecond);
650  ->Unit(benchmark::kMillisecond);
652  ->Unit(benchmark::kMillisecond);
654  ->Unit(benchmark::kMillisecond);
655 
656 } // namespace geometry
657 } // namespace t
658 } // namespace cloudViewer
Common CUDA utilities.
Bounding box structure.
Definition: ecvBBox.h:25
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
std::shared_ptr< ccPointCloud > Crop(const ccBBox &bbox) const
Function to crop ccPointCloud into output ccPointCloud.
virtual ccPointCloud & Transform(const Eigen::Matrix4d &trans) override
Apply transformation (4x4 matrix) to the geometry coordinates.
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
bool resize(unsigned numberOfPoints) override
Resizes all the active features arrays.
std::shared_ptr< ccPointCloud > VoxelDownSample(double voxel_size)
Function to downsample input ccPointCloud into output ccPointCloud with a voxel.
bool reserveThePointsTable(unsigned _numberOfPoints)
Reserves memory to store the points coordinates.
std::shared_ptr< ccPointCloud > SelectByIndex(const std::vector< size_t > &indices, bool invert=false) const
Function to select points from input ccPointCloud into output ccPointCloud.
unsigned size() const override
Definition: PointCloudTpl.h:38
static Tensor Arange(const Scalar start, const Scalar stop, const Scalar step=1, const Dtype dtype=core::Int64, const Device &device=core::Device("CPU:0"))
Create a 1D tensor with evenly spaced values in the given interval.
Definition: Tensor.cpp:436
int64_t GetLength() const
Definition: Tensor.h:1125
Dtype GetDtype() const
Definition: Tensor.h:1164
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Definition: Tensor.cpp:418
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:739
Data class for DemoCropPointCloud contains a point cloud, and cropped.json (a saved selected polygon ...
Definition: Dataset.h:313
Data class for PLYPointCloud contains the fragment.ply point cloud mesh from the Redwood Living Room ...
Definition: Dataset.h:703
std::string GetPath() const
Path to the PLY format point cloud.
Definition: Dataset.h:708
KDTree search parameters for hybrid KNN and radius search.
KDTree search parameters for pure KNN search.
KDTree search parameters for pure radius search.
Base class for KDTree search parameters.
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
A bounding box oriented along an arbitrary frame of reference.
A point cloud contains a list of 3D points.
Definition: PointCloud.h:82
void SetPointNormals(const core::Tensor &value)
Set the value of the "normals" attribute. Convenience function.
Definition: PointCloud.h:198
core::Tensor & GetPointNormals()
Get the value of the "normals" attribute. Convenience function.
Definition: PointCloud.h:130
PointCloud VoxelDownSample(double voxel_size, const std::string &reduction="mean") const
Downsamples a point cloud with a specified voxel size.
Definition: PointCloud.cpp:280
PointCloud Crop(const AxisAlignedBoundingBox &aabb, bool invert=false) const
Function to crop pointcloud into output pointcloud.
void SetPointColors(const core::Tensor &value)
Set the value of the "colors" attribute. Convenience function.
Definition: PointCloud.h:192
PointCloud SelectByIndex(const core::Tensor &indices, bool invert=false, bool remove_duplicates=false) const
Select points from input pointcloud, based on indices list into output point cloud.
Definition: PointCloud.cpp:245
static PointCloud FromLegacy(const cloudViewer::geometry::PointCloud &pcd_legacy, core::Dtype dtype=core::Float32, const core::Device &device=core::Device("CPU:0"))
Create a PointCloud from a legacy CloudViewer PointCloud.
void EstimateNormals(const utility::optional< int > max_nn=30, const utility::optional< double > radius=utility::nullopt)
Function to estimate point normals. If the point cloud normals exist, the estimated normals are orien...
Definition: PointCloud.cpp:619
void SetPointPositions(const core::Tensor &value)
Set the value of the "positions" attribute. Convenience function.
Definition: PointCloud.h:186
core::Tensor & GetPointPositions()
Get the value of the "positions" attribute. Convenience function.
Definition: PointCloud.h:124
std::tuple< PointCloud, core::Tensor > RemoveStatisticalOutliers(size_t nb_neighbors, double std_ratio) const
Remove points that are further away from their nb_neighbor neighbors in average. This function is not...
Definition: PointCloud.cpp:454
PointCloud To(const core::Device &device, bool copy=false) const
Definition: PointCloud.cpp:112
PointCloud UniformDownSample(size_t every_k_points) const
Downsamples a point cloud by selecting every kth index point and its attributes.
Definition: PointCloud.cpp:345
cloudViewer::geometry::PointCloud ToLegacy() const
Convert to a legacy CloudViewer PointCloud.
std::tuple< PointCloud, core::Tensor > ComputeBoundaryPoints(double radius, int max_nn=30, double angle_threshold=90.0) const
Compute the boundary points of a point cloud. The implementation is inspired by the PCL implementatio...
Definition: PointCloud.cpp:574
void RemovePointAttr(const std::string &key)
Definition: PointCloud.h:216
std::tuple< PointCloud, core::Tensor > RemoveRadiusOutliers(size_t nb_points, double search_radius) const
Remove points that have less than nb_points neighbors in a sphere of a given radius.
Definition: PointCloud.cpp:426
PointCloud & Transform(const core::Tensor &transformation)
Transforms the PointPositions and PointNormals (if exist) of the PointCloud.
Definition: PointCloud.cpp:171
#define ENUM_VOXELDOWNSAMPLE_REDUCTION()
Definition: PointCloud.cpp:414
const Dtype Int64
Definition: Dtype.cpp:47
const Dtype Float64
Definition: Dtype.cpp:43
const Dtype Float32
Definition: Dtype.cpp:42
bool ReadPointCloud(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption &params)
std::shared_ptr< ccPointCloud > CreatePointCloudFromFile(const std::string &filename, const std::string &format, bool print_progress)
void To(const core::Tensor &src, core::Tensor &dst, double scale, double offset)
Definition: Image.cpp:17
void RemoveStatisticalOutliers(benchmark::State &state, const core::Device &device, const int nb_neighbors)
Definition: PointCloud.cpp:241
void LegacyCropByOrientedBox(benchmark::State &state, const int no_use)
Definition: PointCloud.cpp:358
void LegacyCropByAxisAlignedBox(benchmark::State &state, const int no_use)
Definition: PointCloud.cpp:343
void UniformDownSample(benchmark::State &state, const core::Device &device, size_t k)
Definition: PointCloud.cpp:94
void SelectByIndex(benchmark::State &state, bool remove_duplicates, const core::Device &device)
Definition: PointCloud.cpp:149
void LegacyRemoveRadiusOutliers(benchmark::State &state, const int nb_points, const double search_radius)
Definition: PointCloud.cpp:292
void LegacyVoxelDownSample(benchmark::State &state, float voxel_size)
Definition: PointCloud.cpp:61
void FromLegacyPointCloud(benchmark::State &state, const core::Device &device)
Definition: PointCloud.cpp:23
void LegacyTransform(benchmark::State &state, const int no_use)
Definition: PointCloud.cpp:112
BENCHMARK_CAPTURE(VoxelDownSample, kReductionMean_0_01, core::Device("CPU:0"), 0.01, kReductionMean) -> Unit(benchmark::kMillisecond)
void LegacyUniformDownSample(benchmark::State &state, size_t k)
Definition: PointCloud.cpp:87
void VoxelDownSample(benchmark::State &state, const core::Device &device, float voxel_size, const std::string &reduction)
Definition: PointCloud.cpp:68
void RemoveRadiusOutliers(benchmark::State &state, const core::Device &device, const int nb_points, const double search_radius)
Definition: PointCloud.cpp:225
void CropByAxisAlignedBox(benchmark::State &state, const core::Device &device)
Definition: PointCloud.cpp:308
Unit(benchmark::kMillisecond)
void LegacySelectByIndex(benchmark::State &state, const int no_use)
Definition: PointCloud.cpp:170
void LegacyRemoveStatisticalOutliers(benchmark::State &state, const int nb_neighbors)
Definition: PointCloud.cpp:277
void Transform(benchmark::State &state, const core::Device &device)
Definition: PointCloud.cpp:127
void ComputeBoundaryPoints(benchmark::State &state, const core::Device &device, const core::Dtype &dtype, const int max_nn, const double radius)
Definition: PointCloud.cpp:256
const std::string kReductionMean
Definition: PointCloud.cpp:408
void EstimateNormals(benchmark::State &state, const core::Device &device, const core::Dtype &dtype, const double voxel_size, const utility::optional< int > max_nn, const utility::optional< double > radius)
Definition: PointCloud.cpp:186
void ToLegacyPointCloud(benchmark::State &state, const core::Device &device)
Definition: PointCloud.cpp:42
data::PLYPointCloud pointcloud_ply
Definition: PointCloud.cpp:58
static const std::string path
Definition: PointCloud.cpp:59
void CropByOrientedBox(benchmark::State &state, const core::Device &device)
Definition: PointCloud.cpp:325
void LegacyEstimateNormals(benchmark::State &state, const double voxel_size, const cloudViewer::geometry::KDTreeSearchParam &search_param)
Definition: PointCloud.cpp:208
bool ReadPointCloud(const std::string &filename, geometry::PointCloud &pointcloud, const cloudViewer::io::ReadPointCloudOption &params)
constexpr nullopt_t nullopt
Definition: Optional.h:136
Generic file read and write utility for python interface.