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 
8 #include <Image.h>
9 #include <RGBDImage.h>
11 #include <ecvPointCloud.h>
12 #include <ecvPolyline.h>
13 
14 #include <vector>
15 
16 #include "pybind/docstring.h"
20 
21 #ifdef _MSC_VER
22 #pragma warning(disable : 4715)
23 #endif
24 
25 namespace cloudViewer {
26 namespace geometry {
27 
28 void pybind_pointcloud(py::module& m) {
29 #ifdef CV_RANSAC_SUPPORT
30  py::class_<geometry::RansacResult> ransacResult(m, "RansacResult",
31  "Ransac result.");
32  py::detail::bind_default_constructor<geometry::RansacResult>(ransacResult);
33  py::detail::bind_copy_functions<geometry::RansacResult>(ransacResult);
34  ransacResult.def(py::init<>())
35  .def("__repr__",
36  [](const geometry::RansacResult& result) {
37  return std::string(
38  "geometry::RansacResult with "
39  "points indices size = ") +
40  std::to_string(result.indices.size()) +
41  " , drawing precision = " +
42  std::to_string(result.getDrawingPrecision()) +
43  " and primitive type = " + result.getTypeName();
44  })
45  .def("get_type_name", &geometry::RansacResult::getTypeName,
46  "Returns type name (sphere, cylinder, etc.).")
47  .def("get_drawing_Precision",
48  &geometry::RansacResult::getDrawingPrecision,
49  "Returns drawing precision (or 0 if feature is not "
50  "supported).")
51  .def("set_drawing_Precision",
52  &geometry::RansacResult::setDrawingPrecision,
53  "Sets drawing precision."
54  "Warning: steps should always be >= "
55  "ccGenericPrimitive::MIN_DRAWING_PRECISION = 4",
56  "steps"_a)
57  .def_readwrite("indices", &geometry::RansacResult::indices,
58  "points indices.")
59  .def_readwrite("primitive", &geometry::RansacResult::primitive,
60  "The ransac primitive mesh shape.");
61  docstring::ClassMethodDocInject(m, "RansacResult", "get_type_name");
62  docstring::ClassMethodDocInject(m, "RansacResult", "get_drawing_Precision");
64  m, "RansacResult", "set_drawing_Precision",
65  {{"steps", "The steps drawing precision."}});
66 
67  // ccPointCloud::RansacParams
68  py::class_<geometry::RansacParams> ransacParam(m, "RansacParams",
69  "Ransac SD Parameters.");
70  py::detail::bind_default_constructor<geometry::RansacParams>(ransacParam);
71  py::detail::bind_copy_functions<geometry::RansacParams>(ransacParam);
72  ransacParam.def(py::init<float>(), "scale"_a)
73  .def("__repr__",
74  [](const geometry::RansacParams& param) {
75  return std::string(
76  "geometry::RansacParams with "
77  "epsilon = ") +
78  std::to_string(param.epsilon) +
79  " and bitmapEpsilon = " +
80  std::to_string(param.bitmapEpsilon) +
81  " and supportPoints = " +
82  std::to_string(param.supportPoints) +
83  " and maxNormalDev_deg = " +
84  std::to_string(param.maxNormalDev_deg) +
85  " and probability = " +
86  std::to_string(param.probability) +
87  " and randomColor = " +
88  std::to_string(param.randomColor) +
89  " and minRadius = " +
90  std::to_string(param.minRadius) +
91  " and maxRadius = " +
92  std::to_string(param.maxRadius);
93  })
94  .def_readwrite("epsilon", &geometry::RansacParams::epsilon,
95  "Distance threshold.")
96  .def_readwrite("bit_map_epsilon",
97  &geometry::RansacParams::bitmapEpsilon,
98  "Bitmap resolution.")
99  .def_readwrite("support_points",
100  &geometry::RansacParams::supportPoints,
101  "This is the minimal numer of points required for a "
102  "primitive.")
103  .def_readwrite(
104  "max_normal_deviation_deg",
105  &geometry::RansacParams::maxNormalDev_deg,
106  "Maximal normal deviation from ideal shape (in degrees).")
107  .def_readwrite("probability", &geometry::RansacParams::probability,
108  "Probability that no better candidate was "
109  "overlooked during sampling.")
110  .def_readwrite("random_color", &geometry::RansacParams::randomColor,
111  "Should the resulting detected shapes sub point "
112  "cloud be colored randomly.")
113  .def_readwrite("prim_enabled_list",
114  &geometry::RansacParams::primEnabled,
115  "RANSAC PRIMITIVE TYPES.")
116  .def_readwrite("min_radius", &geometry::RansacParams::minRadius,
117  "Minimum radius threshold.")
118  .def_readwrite("max_radius", &geometry::RansacParams::maxRadius,
119  "Maximum radius threshold.");
120 
121  // ccPointCloud::RansacParams::RANSAC_PRIMITIVE_TYPES
122  py::native_enum<geometry::RansacParams::RANSAC_PRIMITIVE_TYPES>(
123  ransacParam, "RANSAC_PRIMITIVE_TYPES", "enum.Enum",
124  "Enum class for Ransac Primitive types.")
125  .value("Plane", geometry::RansacParams::RPT_PLANE)
126  .value("Sphere", geometry::RansacParams::RPT_SPHERE)
127  .value("Cylinder", geometry::RansacParams::RPT_CYLINDER)
128  .value("Cone", geometry::RansacParams::RPT_CONE)
129  .value("Torus", geometry::RansacParams::RPT_TORUS)
130  .export_values()
131  .finalize();
132 #endif
133 
134  py::class_<ccPointCloud, PyGeometry<ccPointCloud>,
135  std::shared_ptr<ccPointCloud>, ccGenericPointCloud, ccHObject>
136  pointcloud(m, "ccPointCloud", py::multiple_inheritance(),
137  "ccPointCloud class. A point cloud consists of point "
138  "coordinates, and optionally point colors and point "
139  "normals.");
140  py::detail::bind_default_constructor<ccPointCloud>(pointcloud);
141  py::detail::bind_copy_functions<ccPointCloud>(pointcloud);
142  pointcloud
143  .def(py::init([](const std::string& name) {
144  return new ccPointCloud(name.c_str());
145  }),
146  "name"_a = "cloud")
147  .def(py::init<const std::vector<Eigen::Vector3d>&,
148  const std::string&>(),
149  "Create a PointCloud from points", "points"_a,
150  "name"_a = "cloud")
151  .def("__repr__",
152  [](const ccPointCloud& pcd) {
153  return std::string("ccPointCloud with ") +
154  std::to_string(pcd.size()) + " points.";
155  })
156  .def(py::self + py::self)
157  .def(py::self += py::self)
158  .def("has_covariances", &ccPointCloud::HasCovariances,
159  "Returns ``True`` if the point cloud contains covariances.")
160  .def("normalize_normals", &ccPointCloud::NormalizeNormals,
161  "Normalize point normals to length 1.")
162  .def("paint_uniform_color", &ccPointCloud::PaintUniformColor,
163  "color"_a,
164  "Assigns each point in the PointCloud the same color.")
165  .def("select_by_index", &ccPointCloud::SelectByIndex,
166  "Function to select points from input pointcloud into output "
167  "pointcloud.",
168  "indices"_a, "invert"_a = false)
169  .def("voxel_down_sample", &ccPointCloud::VoxelDownSample,
170  "Function to downsample input pointcloud into output "
171  "pointcloud with "
172  "a voxel. Normals and colors are averaged if they exist.",
173  "voxel_size"_a)
174  .def("voxel_down_sample_and_trace",
176  "Function to downsample using "
177  "ccPointCloud::VoxelDownSample. Also records point "
178  "cloud index before down sampling",
179  "voxel_size"_a, "min_bound"_a, "max_bound"_a,
180  "approximate_class"_a = false)
181  .def("uniform_down_sample", &ccPointCloud::UniformDownSample,
182  "Function to downsample input pointcloud into output "
183  "pointcloud "
184  "uniformly. The sample is performed in the order of the "
185  "points with "
186  "the 0-th point always chosen, not at random.",
187  "every_k_points"_a)
188  .def("random_down_sample", &ccPointCloud::RandomDownSample,
189  "Function to downsample input pointcloud into output "
190  "pointcloud "
191  "randomly. The sample is generated by randomly sampling "
192  "the indexes from the point cloud.",
193  "sampling_ratio"_a)
194  .def("farthest_point_down_sample",
196  "Downsamples input pointcloud into output pointcloud with a "
197  "set of points has farthest distance. The sample is performed "
198  "by selecting the farthest point from previous selected "
199  "points iteratively.",
200  "num_samples"_a,
201  "Index to start downsampling from. Valid index is a "
202  "non-negative number less than number of points in the "
203  "input pointcloud.",
204  "start_index"_a = 0)
205  .def("crop",
206  (std::shared_ptr<ccPointCloud>(ccPointCloud::*)(const ccBBox&)
207  const) &
209  "Function to crop input pointcloud into output pointcloud",
210  "bounding_box"_a)
211  .def("crop",
212  (std::shared_ptr<ccPointCloud>(ccPointCloud::*)(
213  const ecvOrientedBBox&) const) &
215  "Function to crop input pointcloud into output pointcloud",
216  "bounding_box"_a)
217  .def("remove_non_finite_points",
219  "Function to remove non-finite points from the PointCloud",
220  "remove_nan"_a = true, "remove_infinite"_a = true)
221  .def("remove_radius_outlier", &ccPointCloud::RemoveRadiusOutliers,
222  "Function to remove points that have less than nb_points"
223  " in a given sphere of a given radius",
224  "nb_points"_a, "radius"_a)
225  .def("remove_statistical_outlier",
227  "Function to remove points that are further away from their "
228  "neighbors in average",
229  "nb_neighbors"_a, "std_ratio"_a)
230  .def("estimate_normals", &ccPointCloud::EstimateNormals,
231  "Function to compute the normals of a point cloud. Normals "
232  "are oriented with respect to the input point cloud if "
233  "normals exist",
234  "search_param"_a = geometry::KDTreeSearchParamKNN(),
235  "fast_normal_computation"_a = true)
236  .def("orient_normals_to_align_with_direction",
238  "Function to orient the normals of a point cloud",
239  "orientation_reference"_a = Eigen::Vector3d(0.0, 0.0, 1.0))
240  .def("orient_normals_towards_camera_location",
242  "Function to orient the normals of a point cloud",
243  "camera_location"_a = Eigen::Vector3d(0.0, 0.0, 0.0))
244  .def("orient_normals_consistent_tangent_plane",
246  "Function to orient the normals with respect to consistent "
247  "tangent planes",
248  "k"_a)
249  .def("compute_point_cloud_distance",
251  "For each point in the source point cloud, compute the "
252  "distance to "
253  "the target point cloud.",
254  "target"_a)
255  .def("compute_mahalanobis_distance",
257  "Function to compute the Mahalanobis distance for points in a "
258  "point "
259  "cloud. See: "
260  "https://en.wikipedia.org/wiki/Mahalanobis_distance.")
261  .def("compute_nearest_neighbor_distance",
263  "Function to compute the distance from a point to its nearest "
264  "neighbor in the point cloud")
265  .def("compute_resolution", &ccPointCloud::ComputeResolution,
266  "Function to compute the point cloud resolution.")
267  .def("compute_convex_hull", &ccPointCloud::ComputeConvexHull,
268  "Computes the convex hull of the point cloud.")
269  .def("hidden_point_removal", &ccPointCloud::HiddenPointRemoval,
270  "Removes hidden points from a point cloud and returns a mesh "
271  "of the remaining points. Based on Katz et al. 'Direct "
272  "Visibility of Point Sets', 2007. Additional information "
273  "about the choice of radius for noisy point clouds can be "
274  "found in Mehra et. al. 'Visibility of Noisy Point Cloud "
275  "Data', 2010.",
276  "camera_location"_a, "radius"_a)
277  .def("cluster_dbscan", &ccPointCloud::ClusterDBSCAN,
278  "Cluster PointCloud using the DBSCAN algorithm Ester et al., "
279  "'A Density-Based Algorithm for Discovering Clusters in Large "
280  "Spatial Databases with Noise', 1996. Returns a list of point "
281  "labels, -1 indicates noise according to the algorithm.",
282  "eps"_a, "min_points"_a, "print_progress"_a = false)
283 #ifdef CV_RANSAC_SUPPORT
284  .def("execute_ransac", &ccPointCloud::ExecuteRANSAC,
285  "Cluster ccPointCloud using the RANSAC algorithm, "
286  "Wrapper to Schnabel et al. library for automatic"
287  " shape detection in point cloud ,Efficient RANSAC"
288  " for Point - Cloud Shape Detection, Ruwen Schnabel, "
289  "Roland Wahl, Returns a list of ransac point labels"
290  " and shape entity(ccGenericPrimitive)",
291  "params"_a = geometry::RansacParams(),
292  "print_progress"_a = false)
293 #endif
294  .def("segment_plane", &ccPointCloud::SegmentPlane,
295  "Segments a plane in the point cloud using the RANSAC "
296  "algorithm.",
297  "distance_threshold"_a, "ransac_n"_a, "num_iterations"_a)
298  .def("set_point", &ccPointCloud::setEigenPoint,
299  "set point coordinate by given index.", "index"_a, "point"_a)
300  .def("get_point", &ccPointCloud::getEigenPoint,
301  "get point coordinate by given index.", "index"_a)
302  .def("point", &ccPointCloud::getEigenPoint,
303  "get point coordinate by given index.", "index"_a)
304  .def("set_points",
305  py::overload_cast<const std::vector<Eigen::Vector3d>&>(
307  "``float64`` array of shape ``(num_points, 3)``, "
308  "use ``numpy.asarray()`` to access data: Points "
309  "coordinates.",
310  "points"_a)
311  .def("get_points", &ccPointCloud::getEigenPoints,
312  "``float64`` array of shape ``(num_points, 3)``, "
313  "use ``numpy.asarray()`` to access data: Points "
314  "coordinates.")
315  .def("points", &ccPointCloud::getEigenPoints,
316  "``float64`` array of shape ``(num_points, 3)``, "
317  "use ``numpy.asarray()`` to access data: Points "
318  "coordinates.")
319  .def("set_color", &ccPointCloud::setEigenColor,
320  "set point color by given index.", "index"_a, "color"_a)
321  .def("get_color", &ccPointCloud::getEigenColor,
322  "get point color by given index.", "index"_a)
323  .def("color", &ccPointCloud::getEigenColor,
324  "get point color by given index.", "index"_a)
325  .def("set_colors", &ccPointCloud::addEigenColors,
326  "``float64`` array of shape ``(num_points, 3)``, "
327  "range ``[0, 1]`` , use ``numpy.asarray()`` to access "
328  "data: RGB colors of points.",
329  "colors"_a)
330  .def("get_colors", &ccPointCloud::getEigenColors,
331  "``float64`` array of shape ``(num_points, 3)``, "
332  "range ``[0, 1]`` , use ``numpy.asarray()`` to access "
333  "data: RGB colors of points.")
334  .def("colors", &ccPointCloud::getEigenColors,
335  "``float64`` array of shape ``(num_points, 3)``, "
336  "range ``[0, 1]`` , use ``numpy.asarray()`` to access "
337  "data: RGB colors of points.")
338  .def("set_normal", &ccPointCloud::setEigenNormal,
339  "set point normal by given index.", "index"_a, "normal"_a)
340  .def("get_normal", &ccPointCloud::getEigenNormal,
341  "get point normal by given index.", "index"_a)
342  .def("normal", &ccPointCloud::getEigenNormal,
343  "get point normal by given index.", "index"_a)
344  .def("set_normals", &ccPointCloud::addEigenNorms,
345  "``float64`` array of shape ``(num_points, 3)``, "
346  "use ``numpy.asarray()`` to access data: Points normals.",
347  "normals"_a)
348  .def("get_normals", &ccPointCloud::getEigenNormals,
349  "``float64`` array of shape ``(num_points, 3)``, "
350  "use ``numpy.asarray()`` to access data: Points normals.")
351  .def("normals", &ccPointCloud::getEigenNormals,
352  "``float64`` array of shape ``(num_points, 3)``, "
353  "use ``numpy.asarray()`` to access data: Points normals.")
354  .def("unalloacte_points", &ccPointCloud::unalloactePoints,
355  "Erases the cloud points.")
356  .def("unalloacte_colors", &ccPointCloud::unallocateColors,
357  "Erases the cloud colors.")
358  .def("unalloacte_norms", &ccPointCloud::unallocateNorms,
359  "Erases the cloud normals.")
360  .def("colors_have_changed", &ccPointCloud::colorsHaveChanged,
361  R"(Notify a modification of color/scalar field display parameters or contents.)")
362  .def("normals_have_changed", &ccPointCloud::normalsHaveChanged,
363  "Notify a modification of normals display parameters or "
364  "contents.")
365  .def("points_have_changed", &ccPointCloud::pointsHaveChanged,
366  "Notify a modification of points display parameters or "
367  "contents.")
368  .def("reserve", &ccPointCloud::reserve,
369  "Reserves memory for all the active features.",
370  "points_number"_a)
371  .def("reserve_points", &ccPointCloud::reserveThePointsTable,
372  "Reserves memory to store the points coordinates.",
373  "points_number"_a)
374  .def("reserve_colors", &ccPointCloud::reserveTheRGBTable,
375  "Reserves memory to store the RGB colors.")
376  .def("reserve_norms", &ccPointCloud::reserveTheNormsTable,
377  "Reserves memory to store the compressed normals.")
378  .def("resize", &ccPointCloud::resize,
379  "Resizes all the active features arrays.", "points_number"_a)
380  .def("resize_colors", &ccPointCloud::resizeTheRGBTable,
381  "Resizes the RGB colors array.", "fill_with_white"_a = false)
382  .def("resize_norms", &ccPointCloud::reserveTheNormsTable,
383  "Resizes the compressed normals array.")
384  .def("shrink", &ccPointCloud::shrinkToFit,
385  "Removes unused capacity.")
386  .def("reset", &ccPointCloud::reset, " Clears the cloud database.")
387  .def("capacity", &ccPointCloud::capacity,
388  "Returns cloud capacity (i.e. reserved size).")
389  .def("invalidate_bbox", &ccPointCloud::invalidateBoundingBox,
390  "Invalidates bounding box.")
391  .def("set_current_input_sf_index",
393  " Sets the INPUT scalar field index (or -1 if none).",
394  "index"_a)
395  .def("get_current_input_sf_index",
397  "Returns current INPUT scalar field index (or -1 if none).")
398  .def("set_current_output_sf_index",
400  " Sets the OUTPUT scalar field index (or -1 if none).",
401  "index"_a)
402  .def("get_current_output_sf_index",
404  "Returns current OUTPUT scalar field index (or -1 if none).")
405  .def("set_current_sf", &ccPointCloud::setCurrentScalarField,
406  " Sets both the INPUT & OUTPUT scalar field.", "index"_a)
407  .def("sfs_count", &ccPointCloud::getNumberOfScalarFields,
408  "Returns the number of associated (and active) scalar fields.")
409  .def(
410  "get_sf_by_index",
411  [](const ccPointCloud& cloud, std::size_t index) {
412  if (cloud.getScalarField(static_cast<int>(index))) {
413  return std::ref(*cloud.getScalarField(
414  static_cast<int>(index)));
415  } else {
417  "[ccPointCloud] Do not have any scalar "
418  "field!");
419  }
420  },
421  "Returns a pointer to a specific scalar field.", "index"_a)
422  .def(
423  "get_sf_name",
424  [](const ccPointCloud& cloud, std::size_t index) {
425  return std::string(cloud.getScalarFieldName(
426  static_cast<int>(index)));
427  },
428  "Returns the name of a specific scalar field.", "index"_a)
429  .def(
430  "get_sf_index_by_name",
431  [](const ccPointCloud& cloud, const std::string& name) {
432  return cloud.getScalarFieldIndexByName(name.c_str());
433  },
434  "Returns the index of a scalar field represented by its "
435  "name.",
436  "name"_a)
437  .def(
438  "get_current_input_sf",
439  [](const ccPointCloud& cloud) {
440  if (cloud.getCurrentInScalarField()) {
441  return std::ref(*cloud.getCurrentInScalarField());
442  } else {
444  "[ccPointCloud] cloud input does not have "
445  "any scalar field!");
446  }
447  },
448  "Returns the scalar field currently associated to the "
449  "cloud input.")
450  .def(
451  "get_current_output_sf",
452  [](const ccPointCloud& cloud) {
453  if (cloud.getCurrentOutScalarField()) {
454  return std::ref(*cloud.getCurrentOutScalarField());
455  } else {
457  "[ccPointCloud] cloud output does not have "
458  "any scalar field!");
459  }
460  },
461  "Returns the scalar field currently associated to the "
462  "cloud output.")
463  .def(
464  "rename_sf",
465  [](ccPointCloud& cloud, std::size_t index,
466  const std::string& name) {
467  return cloud.renameScalarField(static_cast<int>(index),
468  name.c_str());
469  },
470  "Renames a specific scalar field.", "index"_a, "name"_a)
471  .def(
472  "get_current_displayed_sf",
473  [](const ccPointCloud& cloud) {
474  if (cloud.getCurrentDisplayedScalarField()) {
475  return std::ref(
477  } else {
479  "[ccPointCloud] Do not have scalar "
480  "fields!");
481  }
482  },
483  "Returns the currently displayed scalar (or 0 if none).")
484  .def("set_current_displayed_sf",
486  "Sets the currently displayed scalar field.", "index"_a)
487  .def("get_current_sf_index",
489  "Returns the currently displayed scalar field index (or -1 if "
490  "none).")
491  .def("delete_sf", &ccPointCloud::deleteScalarField,
492  "Deletes a specific scalar field.", "index"_a)
493  .def("delete_all_sfs", &ccPointCloud::deleteAllScalarFields,
494  "Deletes all scalar fields associated to this cloud.")
495  .def(
496  "add_sf",
497  [](ccPointCloud& cloud, const std::string& unique_name) {
498  return cloud.addScalarField(unique_name.c_str());
499  },
500  "Creates a new scalar field and registers it.",
501  "unique_name"_a)
502  .def(
503  "add_sf",
504  [](ccPointCloud& cloud, ccScalarField& sf) {
505  return cloud.addScalarField(&sf);
506  },
507  "Creates a new scalar field and registers it.", "sf"_a)
508  .def("sf_color_scale_shown", &ccPointCloud::sfColorScaleShown,
509  "Returns whether color scale should be displayed or not.")
510  .def("show_sf_color_scale", &ccPointCloud::showSFColorsScale,
511  "Sets whether color scale should be displayed or not.",
512  "state"_a)
513  .def(
514  "compute_gravity_center",
515  [](ccPointCloud& cloud) {
516  return CCVector3d::fromArray(
517  cloud.computeGravityCenter());
518  },
519  "Returns the cloud gravity center")
520  .def(
521  "crop_2d",
522  [](ccPointCloud& cloud, const ccPolyline& polyline,
523  unsigned char ortho_dim, bool inside) {
525  cloud.crop2D(&polyline, ortho_dim, inside);
526  if (!ref || ref->size() == 0) {
527  if (ref) {
528  delete ref;
529  }
530  ref = nullptr;
531  if (polyline.IsEmpty()) {
533  "[ccPointCloud::crop2D] Invalid input "
534  "polyline");
535  }
536  if (ortho_dim > 2) {
538  "[ccPointCloud::crop2D] Invalid input "
539  "ortho_dim");
540  }
541  if (cloud.IsEmpty()) {
543  "[ccPointCloud::crop2D] Cloud is "
544  "empty!");
545  }
546 
547  return std::ref(cloud);
548  }
549 
550  ccPointCloud* croppedCloud = cloud.partialClone(ref);
551  {
552  delete ref;
553  ref = nullptr;
554  }
555  if (!croppedCloud) {
557  "[ccPointCloud::crop2D] Not enough "
558  "memory!");
559  return std::ref(cloud);
560  }
561 
562  return std::ref(*croppedCloud);
563  },
564  "Crops the cloud inside (or outside) a 2D polyline",
565  "polyline"_a, "ortho_dim"_a, "inside"_a = true)
566  .def(
567  "compute_closest_points",
568  [](ccPointCloud& cloud, ccGenericPointCloud& other_cloud,
569  unsigned char octree_level) {
570  return std::ref(*cloud.computeCPSet(
571  other_cloud, nullptr, octree_level));
572  },
573  "Computes the closest point of this cloud relatively to "
574  "another cloud",
575  "other_cloud"_a, "octree_level"_a = 0)
576  .def(
577  "append",
578  [](ccPointCloud& cloud, ccPointCloud& input_cloud,
579  unsigned start_count, bool ignore_children) {
580  return cloud.append(&input_cloud, start_count,
581  ignore_children);
582  },
583  "Appends a cloud to this one", "input_cloud"_a,
584  "start_count"_a, "ignore_children"_a = false)
585  .def(
586  "interpolate_colors_from",
587  [](ccPointCloud& pc, ccPointCloud& other_cloud,
588  unsigned char octree_level) {
589  return pc.interpolateColorsFrom(&other_cloud, nullptr,
590  octree_level);
591  },
592  "Interpolate colors from another cloud (nearest neighbor "
593  "only)",
594  "other_cloud"_a, "octree_level"_a = 0)
595  .def("convert_normal_to_rgb", &ccPointCloud::convertNormalToRGB,
596  "Converts normals to RGB colors.")
597  .def("convert_rgb_to_grey_scale",
599  "Converts RGB to grey scale colors.")
600  .def("add_grey_color", &ccPointCloud::addGreyColor,
601  "Pushes a grey color on stack (shortcut).", "grey"_a)
602  .def("colorize", &ccPointCloud::colorize,
603  "Multiplies all color components of all points by "
604  "coefficients.",
605  "r"_a, "g"_a, "b"_a)
606  .def("set_color_by_banding", &ccPointCloud::setRGBColorByBanding,
607  "Assigns color to points by 'banding'.", "dim"_a,
608  "frequency"_a)
609  .def("has_sensor", &ccPointCloud::hasSensor,
610  "Returns whether the mesh as an associated sensor or not.")
611  .def("invert_normals", &ccPointCloud::invertNormals,
612  "Inverts normals (if any).")
613  .def("convert_current_sf_to_colors",
615  "Converts current scalar field (values & display parameters) "
616  "to RGB colors.",
617  "mix_with_existing_color"_a = false)
618  .def("set_color_with_current_sf",
620  "Sets RGB colors with current scalar field (values & "
621  "parameters).",
622  "mix_with_existing_color"_a = false)
623  .def(
624  "hide_points_by_sf",
625  [](ccPointCloud& cloud, ScalarType min_val,
626  ScalarType max_val) {
627  cloud.hidePointsByScalarValue(min_val, max_val);
628  },
629  "Hides points whose scalar values falls into an interval.",
630  "min_val"_a, "max_val"_a)
631  .def(
632  "hide_points_by_sf",
633  [](ccPointCloud& cloud, std::vector<ScalarType> values) {
634  cloud.hidePointsByScalarValue(values);
635  },
636  "Hides points whose scalar values falls into an interval.",
637  "values"_a)
638  .def(
639  "filter_points_by_sf",
640  [](ccPointCloud& cloud, ScalarType min_val,
641  ScalarType max_val, bool outside) {
642  return std::shared_ptr<ccPointCloud>(
644  min_val, max_val, outside));
645  },
646  "Filters out points whose scalar values falls into an "
647  "interval.",
648  "min_val"_a, "max_val"_a, "outside"_a = false)
649  .def(
650  "filter_points_by_sf",
651  [](ccPointCloud& cloud, std::vector<ScalarType> values,
652  bool outside) {
653  return std::shared_ptr<ccPointCloud>(
654  cloud.filterPointsByScalarValue(values,
655  outside));
656  },
657  "Filters out points whose scalar values falls into an "
658  "interval.",
659  "values"_a, "outside"_a = false)
660  .def(
661  "convert_normal_to_dipdir_sfs",
662  [](ccPointCloud& cloud) {
663  auto dipSF = new ccScalarField("Dip");
664  auto dipDirSF = new ccScalarField("DipDir");
665  if (!cloud.convertNormalToDipDirSFs(dipSF, dipDirSF)) {
667  "[ccPointCloud] Failed to convert normal "
668  "to Dip and DipDir scalar fields!");
669  }
670  return std::make_tuple(
671  std::unique_ptr<ccScalarField, py::nodelete>(
672  dipSF),
673  std::unique_ptr<ccScalarField, py::nodelete>(
674  dipDirSF));
675  },
676  "Converts normals to two scalar fields: 'dip' and 'dip "
677  "direction'.")
678  .def(
679  "clone_this",
680  [](ccPointCloud& cloud, bool ignore_children) {
681  return std::shared_ptr<ccPointCloud>(
682  cloud.cloneThis(nullptr, ignore_children));
683  },
684  "All the main features of the entity are cloned, except "
685  "from the octree and"
686  " the points visibility information.",
687  "ignore_children"_a = true)
688  .def(
689  "partial_clone",
690  [](const ccPointCloud& cloud,
691  std::shared_ptr<cloudViewer::ReferenceCloud> selection) {
692  return std::shared_ptr<ccPointCloud>(
693  cloud.partialClone(selection.get(), nullptr));
694  },
695  "Creates a new point cloud object from a ReferenceCloud "
696  "(selection).",
697  "selection"_a)
698  .def(
699  "enhance_rgb_with_intensity_sf",
700  [](ccPointCloud& cloud, int sf_index,
701  bool use_intensity_range, double min_intensity,
702  double max_intensity) {
703  return cloud.enhanceRGBWithIntensitySF(
704  sf_index, use_intensity_range, min_intensity,
705  max_intensity);
706  },
707  "Enhances the RGB colors with the current scalar field "
708  "(assuming it's intensities).",
709  "sf_index"_a, "use_intensity_range"_a = false,
710  "min_intensity"_a = 0.0, "max_intensity"_a = 1.0)
711  .def(
712  "export_coord_to_sf",
713  [](ccPointCloud& cloud, bool export_x, bool export_y,
714  bool export_z) {
715  bool exportDims[3];
716  exportDims[0] = export_x;
717  exportDims[1] = export_y;
718  exportDims[2] = export_z;
719  return cloud.exportCoordToSF(exportDims);
720  },
721  "Exports the specified coordinate dimension(s) to scalar "
722  "field(s).",
723  "export_x"_a = false, "export_y"_a = false,
724  "export_z"_a = false)
725  .def(
726  "export_normal_to_sf",
727  [](ccPointCloud& cloud, bool export_x, bool export_y,
728  bool export_z) {
729  bool exportDims[3];
730  exportDims[0] = export_x;
731  exportDims[1] = export_y;
732  exportDims[2] = export_z;
733  return cloud.exportCoordToSF(exportDims);
734  },
735  "Exports the specified normal dimension(s) to scalar "
736  "field(s).",
737  "export_x"_a = false, "export_y"_a = false,
738  "export_z"_a = false)
739  .def("estimate_covariances", &ccPointCloud::EstimateCovariances,
740  "Function to compute the covariance matrix for each point "
741  "in the point cloud",
742  "search_param"_a = KDTreeSearchParamKNN())
743  .def_readwrite("covariances", &ccPointCloud::covariances_,
744  "``float64`` array of shape ``(num_points, 3, 3)``, "
745  "use ``numpy.asarray()`` to access data: Points "
746  "covariances.")
747  .def_static(
748  "estimate_point_covariances",
750  "Static function to compute the covariance matrix for "
751  "each "
752  "point in the given point cloud, doesn't change the input",
753  "input"_a, "search_param"_a = KDTreeSearchParamKNN())
754  .def_static(
755  "from",
756  [](const cloudViewer::GenericIndexedCloud& cloud,
757  std::shared_ptr<const ccGenericPointCloud>
758  source_cloud) {
759  return std::shared_ptr<ccPointCloud>(
760  ccPointCloud::From(&cloud, source_cloud.get()));
761  },
762  "'GenericCloud' is a very simple and light interface from "
763  "cloudViewer. It is"
764  "meant to give access to points coordinates of any "
765  "cloud(on the "
766  "condition it implements the GenericCloud interface of "
767  "course). "
768  "See cloudViewer documentation for more information about "
769  "GenericClouds."
770  "As the GenericCloud interface is very simple, only points "
771  "are imported."
772  "Note : throws an 'int' exception in case of error(see "
773  "CTOR_ERRORS)"
774  "-param cloud a GenericCloud structure"
775  "-param source_cloud cloud from which main parameters will "
776  "be imported(optional)",
777  "cloud"_a, "source_cloud"_a = nullptr)
778  .def_static(
779  "from",
780  [](const ccPointCloud& source_cloud,
781  const std::vector<size_t>& indices) {
782  return std::shared_ptr<ccPointCloud>(
783  ccPointCloud::From(&source_cloud, indices));
784  },
785  "Function to select points from input ccPointCloud into "
786  "output ccPointCloud."
787  "Points with indices in param indices are selected",
788  "source_cloud"_a, "indices"_a)
789  .def_static(
790  "create_from_depth_image",
792  R"(Factory function to create a pointcloud from a depth image and a
793  camera. Given depth value d at (u, v) image coordinate, the corresponding 3d
794  point is:
795  - z = d / depth_scale
796  - x = (u - cx) * z / fx
797  - y = (v - cy) * z / fy
798  )",
799  "depth"_a, "intrinsic"_a,
800  "extrinsic"_a = Eigen::Matrix4d::Identity(),
801  "depth_scale"_a = 1000.0, "depth_trunc"_a = 1000.0,
802  "stride"_a = 1, "project_valid_depth_only"_a = true)
803  .def_static("create_from_rgbd_image",
805  "Factory function to create a pointcloud from an RGB-D "
806  "image and a camera. Given depth value d at (u, "
807  "v) image coordinate, the corresponding 3d point is: "
808  R"(- z = d / depth_scale
809  - x = (u - cx) * z / fx
810  - y = (v - cy) * z / fy)",
811  "image"_a, "intrinsic"_a,
812  "extrinsic"_a = Eigen::Matrix4d::Identity(),
813  "project_valid_depth_only"_a = true);
814 
815  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_point");
816  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_points");
817  docstring::ClassMethodDocInject(m, "ccPointCloud", "point");
818  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_point");
819  docstring::ClassMethodDocInject(m, "ccPointCloud", "points");
820  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_points");
821  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_color");
822  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_colors");
823  docstring::ClassMethodDocInject(m, "ccPointCloud", "color");
824  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_color");
825  docstring::ClassMethodDocInject(m, "ccPointCloud", "colors");
826  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_colors");
827  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_normal");
828  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_normals");
829  docstring::ClassMethodDocInject(m, "ccPointCloud", "normal");
830  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_normal");
831  docstring::ClassMethodDocInject(m, "ccPointCloud", "normals");
832  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_normals");
833  docstring::ClassMethodDocInject(m, "ccPointCloud", "normalize_normals");
835  m, "ccPointCloud", "estimate_point_covariances",
836  {{"input", "The input point cloud."},
837  {"search_param",
838  "The KDTree search parameters for neighborhood search."}});
840  m, "ccPointCloud", "estimate_covariances",
841  {{"search_param",
842  "The KDTree search parameters for neighborhood search."}});
844  m, "ccPointCloud", "paint_uniform_color",
845  {{"color", "RGB color for the PointCloud."}});
847  m, "ccPointCloud", "select_by_index",
848  {{"indices", "Indices of points to be selected."},
849  {"invert",
850  "Set to ``True`` to invert the selection of indices."}});
852  m, "ccPointCloud", "voxel_down_sample",
853  {{"voxel_size", "Voxel size to downsample into."},
854  {"invert", "set to ``True`` to invert the selection of indices"}});
856  m, "ccPointCloud", "voxel_down_sample_and_trace",
857  {{"voxel_size", "Voxel size to downsample into."},
858  {"min_bound", "Minimum coordinate of voxel boundaries"},
859  {"max_bound", "Maximum coordinate of voxel boundaries"}});
861  m, "ccPointCloud", "uniform_down_sample",
862  {{"every_k_points",
863  "Sample rate, the selected point indices are [0, k, 2k, ...]"}});
865  m, "ccPointCloud", "random_down_sample",
866  {{"sampling_ratio",
867  "Sampling ratio, the ratio of number of selected points to total "
868  "number of points[0-1]"}});
870  m, "ccPointCloud", "crop",
871  {{"bounding_box", "ccBBox to crop points"}});
873  m, "ccPointCloud", "remove_non_finite_points",
874  {{"remove_nan", "Remove NaN values from the PointCloud"},
875  {"remove_infinite",
876  "Remove infinite values from the PointCloud"}});
878  m, "ccPointCloud", "remove_radius_outlier",
879  {{"nb_points", "Number of points within the radius."},
880  {"radius", "Radius of the sphere."}});
882  m, "ccPointCloud", "remove_statistical_outlier",
883  {{"nb_neighbors", "Number of neighbors around the target point."},
884  {"std_ratio", "Standard deviation ratio."}});
886  m, "ccPointCloud", "estimate_normals",
887  {{"search_param",
888  "The KDTree search parameters for neighborhood search."},
889  {"fast_normal_computation",
890  "If true, the normal estiamtion uses a non-iterative method to "
891  "extract the eigenvector from the covariance matrix. This is "
892  "faster, but is not as numerical stable."}});
894  m, "ccPointCloud", "orient_normals_to_align_with_direction",
895  {{"orientation_reference",
896  "Normals are oriented with respect to orientation_reference."}});
898  m, "ccPointCloud", "orient_normals_towards_camera_location",
899  {{"camera_location",
900  "Normals are oriented with towards the camera_location."}});
902  m, "ccPointCloud", "orient_normals_consistent_tangent_plane",
903  {{"k",
904  "Number of k nearest neighbors used in constructing the "
905  "Riemannian graph used to propogate normal orientation."}});
906  docstring::ClassMethodDocInject(m, "ccPointCloud",
907  "compute_point_cloud_distance",
908  {{"target", "The target point cloud."}});
909  docstring::ClassMethodDocInject(m, "ccPointCloud",
910  "compute_mahalanobis_distance");
911  docstring::ClassMethodDocInject(m, "ccPointCloud",
912  "compute_nearest_neighbor_distance");
913  docstring::ClassMethodDocInject(m, "ccPointCloud", "compute_resolution");
914  docstring::ClassMethodDocInject(m, "ccPointCloud", "compute_convex_hull",
915  {{"input", "The input point cloud."}});
917  m, "ccPointCloud", "hidden_point_removal",
918  {{"input", "The input point cloud."},
919  {"camera_location",
920  "All points not visible from that location will be removed"},
921  {"radius", "The radius of the sperical projection"}});
923  m, "ccPointCloud", "cluster_dbscan",
924  {{"eps",
925  "Density parameter that is used to find neighboring points."},
926  {"min_points", "Minimum number of points to form a cluster."},
927  {"print_progress",
928  "If true the progress is visualized in the console."}});
930  m, "ccPointCloud", "segment_plane",
931  {{"distance_threshold",
932  "Max distance a point can be from the plane model, and still be "
933  "considered an inlier."},
934  {"ransac_n",
935  "Number of initial points to be considered inliers in each "
936  "iteration."},
937  {"num_iterations", "Number of iterations."}});
939  m, "ccPointCloud", "create_from_depth_image",
940  {{"depth",
941  "The input depth image can be either a float image, or a "
942  "uint16_t image."},
943  {"intrinsic", "Intrinsic parameters of the camera."},
944  {"extrnsic", "Extrinsic parameters of the camera."},
945  {"depth_scale", "The depth is scaled by 1 / depth_scale."},
946  {"depth_trunc", "Truncated at depth_trunc distance."},
947  {"stride",
948  "Sampling factor to support coarse point cloud extraction."}});
950  m, "ccPointCloud", "create_from_rgbd_image",
951  {{"image", "The input image."},
952  {"intrinsic", "Intrinsic parameters of the camera."},
953  {"extrnsic", "Extrinsic parameters of the camera."}});
954  docstring::ClassMethodDocInject(m, "ccPointCloud", "unalloacte_points");
955  docstring::ClassMethodDocInject(m, "ccPointCloud", "unalloacte_colors");
956  docstring::ClassMethodDocInject(m, "ccPointCloud", "unalloacte_norms");
957  docstring::ClassMethodDocInject(m, "ccPointCloud", "colors_have_changed");
958  docstring::ClassMethodDocInject(m, "ccPointCloud", "normals_have_changed");
959  docstring::ClassMethodDocInject(m, "ccPointCloud", "points_have_changed");
960  docstring::ClassMethodDocInject(m, "ccPointCloud", "reserve");
961  docstring::ClassMethodDocInject(m, "ccPointCloud", "reserve_points");
962  docstring::ClassMethodDocInject(m, "ccPointCloud", "reserve_colors");
963  docstring::ClassMethodDocInject(m, "ccPointCloud", "reserve_norms");
964  docstring::ClassMethodDocInject(m, "ccPointCloud", "resize");
965  docstring::ClassMethodDocInject(m, "ccPointCloud", "resize_colors");
966  docstring::ClassMethodDocInject(m, "ccPointCloud", "resize_norms");
967  docstring::ClassMethodDocInject(m, "ccPointCloud", "shrink");
968  docstring::ClassMethodDocInject(m, "ccPointCloud", "reset");
969  docstring::ClassMethodDocInject(m, "ccPointCloud", "capacity");
970  docstring::ClassMethodDocInject(m, "ccPointCloud", "invalidate_bbox");
971  docstring::ClassMethodDocInject(m, "ccPointCloud",
972  "set_current_input_sf_index");
973  docstring::ClassMethodDocInject(m, "ccPointCloud",
974  "get_current_input_sf_index");
975  docstring::ClassMethodDocInject(m, "ccPointCloud",
976  "set_current_output_sf_index");
977  docstring::ClassMethodDocInject(m, "ccPointCloud",
978  "get_current_output_sf_index");
979  docstring::ClassMethodDocInject(m, "ccPointCloud", "sfs_count");
980  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_sf_by_index");
981  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_sf_name");
982  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_sf_index_by_name");
983  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_current_input_sf");
984  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_current_output_sf");
985  docstring::ClassMethodDocInject(m, "ccPointCloud", "rename_sf");
986  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_current_sf");
987  docstring::ClassMethodDocInject(m, "ccPointCloud",
988  "set_current_displayed_sf");
989  docstring::ClassMethodDocInject(m, "ccPointCloud",
990  "get_current_displayed_sf");
991  docstring::ClassMethodDocInject(m, "ccPointCloud", "get_current_sf_index");
992  docstring::ClassMethodDocInject(m, "ccPointCloud", "delete_sf");
993  docstring::ClassMethodDocInject(m, "ccPointCloud", "delete_all_sfs");
994  docstring::ClassMethodDocInject(m, "ccPointCloud", "add_sf");
995  docstring::ClassMethodDocInject(m, "ccPointCloud", "sf_color_scale_shown");
996  docstring::ClassMethodDocInject(m, "ccPointCloud", "show_sf_color_scale");
997  docstring::ClassMethodDocInject(m, "ccPointCloud",
998  "compute_gravity_center");
999  docstring::ClassMethodDocInject(m, "ccPointCloud", "crop_2d");
1000  docstring::ClassMethodDocInject(m, "ccPointCloud",
1001  "compute_closest_points");
1002  docstring::ClassMethodDocInject(m, "ccPointCloud", "append");
1003  docstring::ClassMethodDocInject(m, "ccPointCloud",
1004  "interpolate_colors_from");
1005  docstring::ClassMethodDocInject(m, "ccPointCloud", "convert_normal_to_rgb");
1006  docstring::ClassMethodDocInject(m, "ccPointCloud",
1007  "convert_rgb_to_grey_scale");
1008  docstring::ClassMethodDocInject(m, "ccPointCloud", "add_grey_color");
1009  docstring::ClassMethodDocInject(m, "ccPointCloud", "colorize");
1010  docstring::ClassMethodDocInject(m, "ccPointCloud", "set_color_by_banding");
1011  docstring::ClassMethodDocInject(m, "ccPointCloud", "has_sensor");
1012  docstring::ClassMethodDocInject(m, "ccPointCloud", "invert_normals");
1013  docstring::ClassMethodDocInject(m, "ccPointCloud",
1014  "convert_current_sf_to_colors");
1015  docstring::ClassMethodDocInject(m, "ccPointCloud",
1016  "set_color_with_current_sf");
1017  docstring::ClassMethodDocInject(m, "ccPointCloud", "hide_points_by_sf");
1018  docstring::ClassMethodDocInject(m, "ccPointCloud", "filter_points_by_sf");
1019  docstring::ClassMethodDocInject(m, "ccPointCloud",
1020  "convert_normal_to_dipdir_sfs");
1021  docstring::ClassMethodDocInject(m, "ccPointCloud", "clone_this");
1022  docstring::ClassMethodDocInject(m, "ccPointCloud", "partial_clone");
1023  docstring::ClassMethodDocInject(m, "ccPointCloud",
1024  "enhance_rgb_with_intensity_sf");
1025  docstring::ClassMethodDocInject(m, "ccPointCloud", "export_coord_to_sf");
1026  docstring::ClassMethodDocInject(m, "ccPointCloud", "export_normal_to_sf");
1027 }
1028 
1029 void pybind_pointcloud_methods(py::module& m) {}
1030 
1031 } // namespace geometry
1032 } // namespace cloudViewer
std::string name
core::Tensor result
Definition: VtkUtils.cpp:76
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Definition: CVGeom.h:268
Bounding box structure.
Definition: ecvBBox.h:25
A 3D cloud interface with associated features (color, normals, octree, etc.)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
std::tuple< std::shared_ptr< ccPointCloud >, Eigen::MatrixXi, std::vector< std::vector< int > > > VoxelDownSampleAndTrace(double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound, bool approximate_class=false) const
Function to downsample using geometry.ccPointCloud.VoxelDownSample.
std::shared_ptr< ccPointCloud > Crop(const ccBBox &bbox) const
Function to crop ccPointCloud into output ccPointCloud.
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
static std::shared_ptr< ccPointCloud > CreateFromRGBDImage(const cloudViewer::geometry::RGBDImage &image, const cloudViewer::camera::PinholeCameraIntrinsic &intrinsic, const Eigen::Matrix4d &extrinsic=Eigen::Matrix4d::Identity(), bool project_valid_depth_only=true)
Factory function to create a pointcloud from an RGB-D image and a camera model.
void setEigenColor(size_t index, const Eigen::Vector3d &color)
bool sfColorScaleShown() const
Returns whether color scale should be displayed or not.
bool setRGBColorByBanding(unsigned char dim, double freq)
Assigns color to points by 'banding'.
bool hasSensor() const
Returns whether the mesh as an associated sensor or not.
ccPointCloud & NormalizeNormals()
Normalize point normals to length 1.`.
std::tuple< std::shared_ptr< ccMesh >, std::vector< size_t > > HiddenPointRemoval(const Eigen::Vector3d &camera_location, const double radius) const
This is an implementation of the Hidden Point Removal operator described in Katz et....
bool convertNormalToRGB()
Converts normals to RGB colors.
std::vector< Eigen::Vector3d > getEigenColors() const
bool EstimateNormals(const cloudViewer::geometry::KDTreeSearchParam &search_param=cloudViewer::geometry::KDTreeSearchParamKNN(), bool fast_normal_computation=true)
Function to compute the normals of a point cloud.
void unallocateColors()
Erases the cloud colors.
static std::shared_ptr< ccPointCloud > CreateFromDepthImage(const cloudViewer::geometry::Image &depth, const cloudViewer::camera::PinholeCameraIntrinsic &intrinsic, const Eigen::Matrix4d &extrinsic=Eigen::Matrix4d::Identity(), double depth_scale=1000.0, double depth_trunc=1000.0, int stride=1, bool project_valid_depth_only=true)
Factory function to create a pointcloud from a depth image and a camera model.
void deleteAllScalarFields() override
Deletes all scalar fields associated to this cloud.
void setEigenNormal(size_t index, const Eigen::Vector3d &normal)
void addEigenNorms(const std::vector< Eigen::Vector3d > &normals)
bool HasCovariances() const
Returns 'true' if the point cloud contains per-point covariance matrix.
bool OrientNormalsTowardsCameraLocation(const Eigen::Vector3d &camera_location=Eigen::Vector3d::Zero())
Function to orient the normals of a point cloud.
std::vector< double > ComputeNearestNeighborDistance() const
std::tuple< Eigen::Vector4d, std::vector< size_t > > SegmentPlane(const double distance_threshold=0.01, const int ransac_n=3, const int num_iterations=100) const
Segment ccPointCloud plane using the RANSAC algorithm.
Eigen::Vector3d getEigenNormal(size_t index) const
std::vector< double > ComputeMahalanobisDistance() const
Function to compute the Mahalanobis distance for points in an input point cloud.
bool convertRGBToGreyScale()
Converts RGB to grey scale colors.
double ComputeResolution() const
std::shared_ptr< ccPointCloud > FarthestPointDownSample(const size_t num_samples, const size_t start_index=0) const
Function to downsample input pointcloud into output pointcloud with a set of points has farthest dist...
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
bool interpolateColorsFrom(ccGenericPointCloud *cloud, cloudViewer::GenericProgressCallback *progressCb=nullptr, unsigned char octreeLevel=0)
Interpolate colors from another cloud (nearest neighbor only)
bool enhanceRGBWithIntensitySF(int sfIdx, bool useCustomIntensityRange=false, double minI=0.0, double maxI=1.0)
virtual bool IsEmpty() const override
bool resizeTheRGBTable(bool fillWithWhite=false)
Resizes the RGB colors array.
void normalsHaveChanged()
Notify a modification of normals display parameters or contents.
void showSFColorsScale(bool state)
Sets whether color scale should be displayed or not.
void unalloactePoints()
Erases the cloud points.
void addGreyColor(ColorCompType g)
Pushes a grey color on stack (shortcut)
void OrientNormalsConsistentTangentPlane(size_t k)
Function to consistently orient estimated normals based on consistent tangent planes as described in ...
void invalidateBoundingBox() override
Invalidates bounding box.
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
std::tuple< std::shared_ptr< ccPointCloud >, std::vector< size_t > > RemoveStatisticalOutliers(size_t nb_neighbors, double std_ratio) const
Function to remove points that are further away from their nb_neighbor neighbors in average.
bool OrientNormalsToAlignWithDirection(const Eigen::Vector3d &orientation_reference=Eigen::Vector3d(0.0, 0.0, 1.0))
Function to orient the normals of a point cloud.
bool exportCoordToSF(bool exportDims[3])
Exports the specified coordinate dimension(s) to scalar field(s)
std::vector< int > ClusterDBSCAN(double eps, size_t min_points, bool print_progress=false) const
Cluster ccPointCloud using the DBSCAN algorithm Ester et al., "A Density-Based Algorithm for Discover...
void pointsHaveChanged()
Notify a modification of points display parameters or contents.
ccPointCloud & RemoveNonFinitePoints(bool remove_nan=true, bool remove_infinite=true)
Remove all points fromt he point cloud that have a nan entry, or infinite entries.
bool colorize(float r, float g, float b)
Multiplies all color components of all points by coefficients.
std::shared_ptr< ccPointCloud > RandomDownSample(double sampling_ratio) const
Function to downsample input pointcloud into output pointcloud randomly.
void hidePointsByScalarValue(ScalarType minVal, ScalarType maxVal)
Hides points whose scalar values falls into an interval.
bool reserveTheNormsTable()
Reserves memory to store the compressed normals.
bool convertNormalToDipDirSFs(ccScalarField *dipSF, ccScalarField *dipDirSF)
Converts normals to two scalar fields: 'dip' and 'dip direction'.
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
int getCurrentDisplayedScalarFieldIndex() const
Returns the currently displayed scalar field index (or -1 if none)
std::tuple< std::shared_ptr< ccPointCloud >, std::vector< size_t > > RemoveRadiusOutliers(size_t nb_points, double search_radius) const
Function to remove points that have less than nb_points in a sphere of a given radius.
ccPointCloud * cloneThis(ccPointCloud *destCloud=nullptr, bool ignoreChildren=false)
Clones this entity.
void unallocateNorms()
Erases the cloud normals.
static std::vector< Eigen::Matrix3d > EstimatePerPointCovariances(const ccPointCloud &input, const cloudViewer::geometry::KDTreeSearchParam &search_param=cloudViewer::geometry::KDTreeSearchParamKNN())
Static function to compute the covariance matrix for each point of a point cloud. Doesn't change the ...
static ccPointCloud * From(const cloudViewer::GenericIndexedCloud *cloud, const ccGenericPointCloud *sourceCloud=nullptr)
Creates a new point cloud object from a GenericIndexedCloud.
bool resize(unsigned numberOfPoints) override
Resizes all the active features arrays.
void deleteScalarField(int index) override
Deletes a specific scalar field.
cloudViewer::ReferenceCloud * crop2D(const ccPolyline *poly, unsigned char orthoDim, bool inside=true)
Crops the cloud inside (or outside) a 2D polyline.
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
std::shared_ptr< ccPointCloud > VoxelDownSample(double voxel_size)
Function to downsample input ccPointCloud into output ccPointCloud with a voxel.
std::vector< Eigen::Matrix3d > covariances_
Covariance Matrix for each point.
Eigen::Vector3d getEigenColor(size_t index) const
QSharedPointer< cloudViewer::ReferenceCloud > computeCPSet(ccGenericPointCloud &otherCloud, cloudViewer::GenericProgressCallback *progressCb=nullptr, unsigned char octreeLevel=0)
Computes the closest point of this cloud relatively to another cloud.
void addEigenColors(const std::vector< Eigen::Vector3d > &colors)
void shrinkToFit()
Removes unused capacity.
std::vector< double > ComputePointCloudDistance(const ccPointCloud &target)
Function to compute the point to point distances between point clouds.
ccPointCloud * filterPointsByScalarValue(ScalarType minVal, ScalarType maxVal, bool outside=false)
Filters out points whose scalar values falls into an interval.
bool convertCurrentScalarFieldToColors(bool mixWithExistingColor=false)
void colorsHaveChanged()
CCVector3 computeGravityCenter()
Returns the cloud gravity center.
void EstimateCovariances(const cloudViewer::geometry::KDTreeSearchParam &search_param=cloudViewer::geometry::KDTreeSearchParamKNN())
Function to compute the covariance matrix for each point of a point cloud.
ccPointCloud * partialClone(const cloudViewer::ReferenceCloud *selection, int *warnings=nullptr, bool withChildEntities=true) const
Creates a new point cloud object from a ReferenceCloud (selection)
ccPointCloud & PaintUniformColor(const Eigen::Vector3d &color)
Assigns each vertex in the ccMesh the same color.
std::tuple< std::shared_ptr< ccMesh >, std::vector< size_t > > ComputeConvexHull() const
Function that computes the convex hull of the point cloud using qhull.
bool reserveThePointsTable(unsigned _numberOfPoints)
Reserves memory to store the points coordinates.
bool setRGBColorWithCurrentScalarField(bool mixWithExistingColor=false)
Sets RGB colors with current scalar field (values & parameters)
const ccPointCloud & append(ccPointCloud *cloud, unsigned pointCountBefore, bool ignoreChildren=false)
Appends a cloud to this one.
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.
std::vector< Eigen::Vector3d > getEigenNormals() const
std::shared_ptr< ccPointCloud > UniformDownSample(size_t every_k_points) const
Function to downsample input ccPointCloud into output ccPointCloud uniformly.
void invertNormals()
Inverts normals (if any)
Colored polyline.
Definition: ecvPolyline.h:24
virtual bool IsEmpty() const override
Definition: ecvPolyline.h:188
A scalar field associated to display-related parameters.
A generic 3D point cloud with index-based point access.
ScalarField * getCurrentOutScalarField() const
Returns the scalar field currently associated to the cloud output.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
void reset()
Clears the cloud database.
int getCurrentInScalarFieldIndex()
Returns current INPUT scalar field index (or -1 if none)
void setCurrentOutScalarField(int index)
Sets the OUTPUT scalar field.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
void setCurrentScalarField(int index)
Sets both the INPUT & OUTPUT scalar field.
int getCurrentOutScalarFieldIndex()
Returns current OUTPUT scalar field index (or -1 if none)
unsigned size() const override
Definition: PointCloudTpl.h:38
bool renameScalarField(int index, const char *newName)
Renames a specific scalar field.
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
void setEigenPoint(size_t index, const Eigen::Vector3d &point)
std::vector< Eigen::Vector3d > getEigenPoints() const
void setCurrentInScalarField(int index)
Sets the INPUT scalar field.
unsigned capacity() const
Returns cloud capacity (i.e. reserved size)
Eigen::Vector3d getEigenPoint(size_t index) const
void addPoints(const std::vector< CCVector3 > &points)
ScalarField * getCurrentInScalarField() const
Returns the scalar field currently associated to the cloud input.
A very simple point cloud (no point duplication)
unsigned size() const override
Returns the number of points.
KDTree search parameters for pure KNN search.
#define LogWarning(...)
Definition: Logging.h:72
void ClassMethodDocInject(py::module &pybind_module, const std::string &class_name, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
Definition: docstring.cpp:27
void pybind_pointcloud(py::module &m)
Definition: pointcloud.cpp:28
void pybind_pointcloud_methods(py::module &m)
Generic file read and write utility for python interface.
std::string to_string(const T &n)
Definition: Common.h:20