-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add uniform and random down sample methods in Tensor PointCloud #5202
Conversation
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
return pcd_down; | ||
} | ||
|
||
PointCloud PointCloud::RandomDownSample(double sampling_ratio) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- For reproducible experiments, we need the ability to set the random seed for all RNG calls by Open3D. One way to achieve this is with a singleton RNG, with some care for concurrent access.
- CUDA has an RNG that will likely be faster for CUDA tensors.
I appreciate the effort, but I was wondering if there is any use case for this functionality? Here Do we have a reference implementation/inspiration of such functionality in PCL or other 3D data processing packages? |
Voxel down-sampling is actually a uniform down-sample in a way. I guess users might appreciate an improved voxel-down-sample functionality over other filtering options. |
The
I agree with this because currenly the voxel down sample method in tensor based pcd only return coordinates of voxels, leading to the inconsistent with legacy version and other library's behaviour. |
cpp/open3d/t/geometry/PointCloud.h
Outdated
/// \param voxel_size Voxel size. A positive number. | ||
PointCloud VoxelDownSample(double voxel_size, | ||
const core::HashBackendType &backend = | ||
core::HashBackendType::Default) const; | ||
|
||
/// \brief Downsamples a point cloud uniformly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please elaborate on the description such as:
Downsamples a point cloud, by selecting every kth index point and its attributes.
Similarly for RandomDownSample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cpp/pybind/t/geometry/pointcloud.cpp
Outdated
@@ -198,6 +198,18 @@ The attributes of the point cloud have different levels:: | |||
}, | |||
"Downsamples a point cloud with a specified voxel size.", | |||
"voxel_size"_a); | |||
pointcloud.def( | |||
"uniform_down_sample", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may use the following:
Instead of
pointcloud.def(
"uniform_down_sample",
[](const PointCloud& pointcloud, const size_t every_k_points) {
return pointcloud.UniformDownSample(every_k_points);
},
"Downsamples a point cloud uniformly.", "every_k_points"_a);
you may try:
pointcloud.def(
"uniform_down_sample", &UniformDownSample,
"Downsamples a point cloud uniformly.", "every_k_points"_a);
similarly to other functions.
Also, test the same if it is working, you may find similar use in pybind folder for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 5 unresolved discussions (waiting on @yuecideng and @yxlao)
cpp/tests/t/geometry/PointCloud.cpp
line 770 at r2 (raw file):
core::Device device = GetParam(); // Value test
Add a .
cpp/tests/t/geometry/PointCloud.cpp
line 789 at r2 (raw file):
core::Device device = GetParam(); // Value test
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 5 unresolved discussions (waiting on @reyanshsolis, @yuecideng, and @yxlao)
cpp/tests/t/geometry/PointCloud.cpp
line 770 at r2 (raw file):
Previously, reyanshsolis (Rishabh Singh) wrote…
Add a
.
Done
cpp/tests/t/geometry/PointCloud.cpp
line 789 at r2 (raw file):
Previously, reyanshsolis (Rishabh Singh) wrote…
same
Done
Update with using open3d random singleton. CUDA implementation will be added in the future PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, 2 of 3 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: 4 of 5 files reviewed, 8 unresolved discussions (waiting on @reyanshsolis, @ssheorey, @yuecideng, and @yxlao)
cpp/benchmarks/t/geometry/PointCloud.cpp
line 123 at r5 (raw file):
pcd = pcd.To(device); // Warp up
typo: warm up.
cpp/pybind/t/geometry/pointcloud.cpp
line 204 at r5 (raw file):
"Downsamples a point cloud by selecting every kth index " "point and its attributes.", "every_k_points"_a);
Same as below, call docstring::ClassMethodDocInject
cpp/pybind/t/geometry/pointcloud.cpp
line 208 at r5 (raw file):
"Downsample a pointcloud by selecting random index point " "and its attributes.", "sampling_ratio"_a);
We need to call docstring::ClassMethodDocInject
to enable the docs. In our case, we need to document sampling_ratio
by passing in a dictionary.
Code quote:
docstring::ClassMethodDocInject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 5 files reviewed, 8 unresolved discussions (waiting on @reyanshsolis, @ssheorey, @yuecideng, and @yxlao)
cpp/pybind/t/geometry/pointcloud.cpp
line 208 at r5 (raw file):
Previously, yxlao (Yixing Lao) wrote…
We need to call
docstring::ClassMethodDocInject
to enable the docs. In our case, we need to documentsampling_ratio
by passing in a dictionary.
Should we also add docstring::ClassMethodDocInject
to the recently added functions, like SelectByMask
, SelectByIndex
, RemoveRadiusOutliers
? I think it is better to add them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 5 files reviewed, 9 unresolved discussions (waiting on @reyanshsolis, @ssheorey, @yuecideng, and @yxlao)
cpp/open3d/t/geometry/PointCloud.cpp
line 359 at r6 (raw file):
false, false); } else { utility::LogError("RandomDownSample is not supported on GPU.");
LGTM, after fixing this. We can copy the indices from CPU to CUDA for now. This is required to pass the CUDA CI test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 5 files reviewed, 9 unresolved discussions (waiting on @reyanshsolis, @ssheorey, @yuecideng, and @yxlao)
Update
Use tensor slicing stead of indexing for uniform sampling, which makes it more faster.
This change is