10 #include <benchmark/benchmark.h>
25 unsigned int num_points = 1000000;
28 legacy_pcd.
resize(num_points);
35 for (
auto _ : state) {
43 int64_t num_points = 1000000;
52 for (
auto _ : state) {
63 for (
auto _ : state) {
64 pcd->VoxelDownSample(voxel_size);
71 const std::string& reduction) {
81 for (
auto _ : state) {
89 for (
auto _ : state) {
90 pcd->UniformDownSample(k);
101 pcd = pcd.
To(device);
106 for (
auto _ : state) {
116 Eigen::Matrix4d transformation = Eigen::Matrix4d::Identity();
117 transformation.block<3, 1>(0, 3) = Eigen::Vector3d(1, 2, 3);
122 for (
auto _ : state) {
123 pcd_transformed = pcd.
Transform(transformation);
130 pcd = pcd.
To(device);
133 core::Tensor transformation = core::Tensor::Init<double>({{1, 0, 0, 1.0},
143 for (
auto _ : state) {
144 pcd_transformed = pcd.
Transform(transformation);
150 bool remove_duplicates,
154 pcd = pcd.
To(device);
164 for (
auto _ : state) {
174 const size_t num_points = pcd.
size();
175 std::vector<size_t> indices(num_points);
176 std::iota(indices.begin(), indices.end(), 0);
181 for (
auto _ : state) {
189 const double voxel_size,
203 for (
auto _ : state) {
209 benchmark::State& state,
210 const double voxel_size,
218 pcd_down->EstimateNormals(search_param,
true);
220 for (
auto _ : state) {
221 pcd_down->EstimateNormals(search_param,
true);
228 const double search_radius) {
236 for (
auto _ : state) {
243 const int nb_neighbors) {
251 for (
auto _ : state) {
260 const double radius) {
265 pcd = pcd.
To(device);
272 for (
auto _ : state) {
278 const int nb_neighbors) {
285 pcd_down->RemoveStatisticalOutliers(nb_neighbors, 1.0);
287 for (
auto _ : state) {
288 pcd_down->RemoveStatisticalOutliers(nb_neighbors, 1.0);
294 const double search_radius) {
301 pcd_down->RemoveRadiusOutliers(nb_points, search_radius);
303 for (
auto _ : state) {
304 pcd_down->RemoveRadiusOutliers(nb_points, search_radius);
312 pcd = pcd.
To(device);
314 core::Tensor::Init<float>({0, 0, 0}, device),
315 core::Tensor::Init<float>({1, 1, 1}, device));
320 for (
auto _ : state) {
329 pcd = pcd.
To(device);
331 core::Tensor::Init<float>({0, 0, 0}, device),
333 core::Tensor::Init<float>({1, 1, 1}, device));
338 for (
auto _ : state) {
348 Eigen::Vector3d(1, 1, 1));
353 for (
auto _ : state) {
363 Eigen::Matrix3d::Identity(),
364 Eigen::Vector3d(1, 1, 1));
369 for (
auto _ : state) {
375 ->Unit(benchmark::kMillisecond);
378 ->Unit(benchmark::kMillisecond);
380 #ifdef BUILD_CUDA_MODULE
382 ->Unit(benchmark::kMillisecond);
385 ->Unit(benchmark::kMillisecond);
388 #define ENUM_VOXELSIZE(DEVICE, REDUCTION) \
389 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_01, DEVICE, 0.01, \
391 ->Unit(benchmark::kMillisecond); \
392 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_02, DEVICE, 0.08, \
394 ->Unit(benchmark::kMillisecond); \
395 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_04, DEVICE, 0.04, \
397 ->Unit(benchmark::kMillisecond); \
398 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_08, DEVICE, 0.08, \
400 ->Unit(benchmark::kMillisecond); \
401 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_16, DEVICE, 0.16, \
403 ->Unit(benchmark::kMillisecond); \
404 BENCHMARK_CAPTURE(VoxelDownSample, REDUCTION##_0_32, DEVICE, 0.32, \
406 ->Unit(benchmark::kMillisecond);
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)
414 #define ENUM_VOXELDOWNSAMPLE_REDUCTION() \
415 ENUM_VOXELSIZE(core::Device("CPU:0"), kReductionMean)
419 ->Unit(benchmark::kMillisecond);
421 ->Unit(benchmark::kMillisecond);
423 ->Unit(benchmark::kMillisecond);
425 ->Unit(benchmark::kMillisecond);
427 ->Unit(benchmark::kMillisecond);
429 ->Unit(benchmark::kMillisecond);
433 ->
Unit(benchmark::kMillisecond);
435 ->
Unit(benchmark::kMillisecond);
437 ->
Unit(benchmark::kMillisecond);
439 ->
Unit(benchmark::kMillisecond);
441 ->
Unit(benchmark::kMillisecond);
443 ->
Unit(benchmark::kMillisecond);
446 ->
Unit(benchmark::kMillisecond);
449 ->
Unit(benchmark::kMillisecond);
452 CPU(remove duplicates),
454 core::Device("CPU:0"))
455 ->
Unit(benchmark::kMillisecond);
457 #ifdef BUILD_CUDA_MODULE
459 ->Unit(benchmark::kMillisecond);
461 ->Unit(benchmark::kMillisecond);
463 ->Unit(benchmark::kMillisecond);
465 ->Unit(benchmark::kMillisecond);
467 ->Unit(benchmark::kMillisecond);
469 CUDA(remove duplicates),
472 ->Unit(benchmark::kMillisecond);
476 CPU F32 Hybrid[0.02 | 30 | 0.06],
482 ->Unit(benchmark::kMillisecond);
484 CPU F64 Hybrid[0.02 | 30 | 0.06],
490 ->Unit(benchmark::kMillisecond);
492 CPU F32 KNN[0.02 | 30],
498 ->Unit(benchmark::kMillisecond);
500 CPU F64 KNN[0.02 | 30],
506 ->Unit(benchmark::kMillisecond);
508 CPU F32 Radius[0.02 | 0.06],
514 ->Unit(benchmark::kMillisecond);
516 CPU F64 Radius[0.02 | 0.06],
522 ->Unit(benchmark::kMillisecond);
523 #ifdef BUILD_CUDA_MODULE
525 CUDA F32 Hybrid[0.02 | 30 | 0.06],
531 ->Unit(benchmark::kMillisecond);
533 CUDA F64 Hybrid[0.02 | 30 | 0.06],
539 ->Unit(benchmark::kMillisecond);
541 CUDA F32 KNN[0.02 | 30],
547 ->Unit(benchmark::kMillisecond);
549 CUDA F64 KNN[0.02 | 30],
555 ->Unit(benchmark::kMillisecond);
557 CUDA F32 Radius[0.02 | 0.06],
563 ->Unit(benchmark::kMillisecond);
565 CUDA F64 Radius[0.02 | 0.06],
571 ->Unit(benchmark::kMillisecond);
578 Legacy Hybrid[0.02 | 30 | 0.06],
581 ->Unit(benchmark::kMillisecond);
584 Legacy KNN[0.02 | 30],
587 ->Unit(benchmark::kMillisecond);
590 Legacy Radius[0.02 | 0.06],
593 ->Unit(benchmark::kMillisecond);
597 ->Unit(benchmark::kMillisecond);
599 ->Unit(benchmark::kMillisecond);
601 ->Unit(benchmark::kMillisecond);
603 ->Unit(benchmark::kMillisecond);
610 ->Unit(benchmark::kMillisecond);
617 ->Unit(benchmark::kMillisecond);
618 #ifdef BUILD_CUDA_MODULE
621 ->Unit(benchmark::kMillisecond);
623 ->Unit(benchmark::kMillisecond);
625 ->Unit(benchmark::kMillisecond);
630 ->Unit(benchmark::kMillisecond);
637 ->Unit(benchmark::kMillisecond);
644 ->Unit(benchmark::kMillisecond);
648 ->Unit(benchmark::kMillisecond);
650 ->Unit(benchmark::kMillisecond);
652 ->Unit(benchmark::kMillisecond);
654 ->Unit(benchmark::kMillisecond);
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
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.
int64_t GetLength() const
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Tensor To(Dtype dtype, bool copy=false) const
Data class for DemoCropPointCloud contains a point cloud, and cropped.json (a saved selected polygon ...
Data class for PLYPointCloud contains the fragment.ply point cloud mesh from the Redwood Living Room ...
std::string GetPath() const
Path to the PLY format point cloud.
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.
void SetPointNormals(const core::Tensor &value)
Set the value of the "normals" attribute. Convenience function.
core::Tensor & GetPointNormals()
Get the value of the "normals" attribute. Convenience function.
PointCloud VoxelDownSample(double voxel_size, const std::string &reduction="mean") const
Downsamples a point cloud with a specified voxel size.
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.
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.
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...
void SetPointPositions(const core::Tensor &value)
Set the value of the "positions" attribute. Convenience function.
core::Tensor & GetPointPositions()
Get the value of the "positions" attribute. Convenience function.
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...
PointCloud To(const core::Device &device, bool copy=false) const
PointCloud UniformDownSample(size_t every_k_points) const
Downsamples a point cloud by selecting every kth index point and its attributes.
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...
void RemovePointAttr(const std::string &key)
bool HasPointNormals() const
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.
PointCloud & Transform(const core::Tensor &transformation)
Transforms the PointPositions and PointNormals (if exist) of the PointCloud.
#define ENUM_VOXELDOWNSAMPLE_REDUCTION()
bool ReadPointCloud(const std::string &filename, ccPointCloud &pointcloud, const ReadPointCloudOption ¶ms)
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)
void RemoveStatisticalOutliers(benchmark::State &state, const core::Device &device, const int nb_neighbors)
void LegacyCropByOrientedBox(benchmark::State &state, const int no_use)
void LegacyCropByAxisAlignedBox(benchmark::State &state, const int no_use)
void UniformDownSample(benchmark::State &state, const core::Device &device, size_t k)
void SelectByIndex(benchmark::State &state, bool remove_duplicates, const core::Device &device)
void LegacyRemoveRadiusOutliers(benchmark::State &state, const int nb_points, const double search_radius)
void LegacyVoxelDownSample(benchmark::State &state, float voxel_size)
void FromLegacyPointCloud(benchmark::State &state, const core::Device &device)
void LegacyTransform(benchmark::State &state, const int no_use)
BENCHMARK_CAPTURE(VoxelDownSample, kReductionMean_0_01, core::Device("CPU:0"), 0.01, kReductionMean) -> Unit(benchmark::kMillisecond)
void LegacyUniformDownSample(benchmark::State &state, size_t k)
void VoxelDownSample(benchmark::State &state, const core::Device &device, float voxel_size, const std::string &reduction)
void RemoveRadiusOutliers(benchmark::State &state, const core::Device &device, const int nb_points, const double search_radius)
void CropByAxisAlignedBox(benchmark::State &state, const core::Device &device)
Unit(benchmark::kMillisecond)
void LegacySelectByIndex(benchmark::State &state, const int no_use)
void LegacyRemoveStatisticalOutliers(benchmark::State &state, const int nb_neighbors)
void Transform(benchmark::State &state, const core::Device &device)
void ComputeBoundaryPoints(benchmark::State &state, const core::Device &device, const core::Dtype &dtype, const int max_nn, const double radius)
const std::string kReductionMean
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)
void ToLegacyPointCloud(benchmark::State &state, const core::Device &device)
data::PLYPointCloud pointcloud_ply
static const std::string path
void CropByOrientedBox(benchmark::State &state, const core::Device &device)
void LegacyEstimateNormals(benchmark::State &state, const double voxel_size, const cloudViewer::geometry::KDTreeSearchParam &search_param)
bool ReadPointCloud(const std::string &filename, geometry::PointCloud &pointcloud, const cloudViewer::io::ReadPointCloudOption ¶ms)
constexpr nullopt_t nullopt
Generic file read and write utility for python interface.