Skip to content
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

sampling function that limits the number of points in pointcloud #3620

Closed
zubair1502 opened this issue Feb 1, 2020 · 5 comments
Closed

sampling function that limits the number of points in pointcloud #3620

zubair1502 opened this issue Feb 1, 2020 · 5 comments
Labels
kind: question Type of issue

Comments

@zubair1502
Copy link

Operation system : Windows
Compiler : VS2013
PCL version : all in one installer 1.8.0

Hello,
I am working on rgb-d data which i converted it into pointcloud by using PCL library after that, I extracted the ROI by using cropbox function. Now the cropped clouds are unorganised and contain variable number of points in each pointcloud.
I want to process these cropped clouds in such a way so that they contain equal number of points in all pointclouds. For this I can do either upsampling or downsampling.

I have checked the uniform mesh sampling function but I am confused that whether this function will work for me or not because it is for meshes and my pointclouds contain only vertices. When I tried this, visualization shows that the cloud now like a straight line.
I have tried also some downsampling functions like voxal grid but the problem still remain same.
for example :
After cropping, 1 cloud contain 2535 points and 2 cloud contain 4368 points.
I want any method that can limit the equal number of points in both cloud.
for example : for downsampling both cloud should contain 2000 points and in case of up sampling, both clouds should contain 6000 points.

Please any help, Thank you.

@haritha-j
Copy link
Contributor

You could try voxel grid, but have the leaf size adjust for each cloud, based on the bounds of the point cloud in such a way that, the number of voxels for both clouds remain the same. When the number of voxels are the same, since there is only one point per each voxel, i presume that the number of points should be the same for both clouds.

If you don't want to get into all that, and don't mind random downsampling, then looping through the pointcloud once and deleting random points until a fixed number of points remain should be a pretty trivial task.

@kunaltyagi kunaltyagi added the status: triage Labels incomplete label Mar 4, 2020
@taketwo
Copy link
Member

taketwo commented Mar 4, 2020

When the number of voxels are the same, since there is only one point per each voxel, i presume that the number of points should be the same for both clouds.

There is at most one point per each voxel. Naturally, some voxels will be empty because the pointcloud is not covering the entire 3D space of the voxel grid.

then looping through the pointcloud once and deleting random points until a fixed number of points remain should be a pretty trivial task.

That would be my suggestion too. I don't think we have a ready-made solution in PCL, but it's indeed very trivial to implement from scratch.

@taketwo taketwo added kind: question Type of issue needs: author reply Specify why not closed/merged yet and removed status: triage Labels incomplete labels Mar 4, 2020
@zubair1502
Copy link
Author

@haritha-j @taketwo @kunaltyagi thank you so much for your reponses. Yes you guys are right, I tried random downsampling and it works for me because I am dealing with thousands of clouds and I can not check every single cloud by applying voxel grid filter. I wanted to apply one filter that should work on all the clouds.

In my case, I don't have to downsampled huge number of points like from 10,000 to 2,000 only and for this, random downsampling is working fine without loosing much information.

@haritha-j
Copy link
Contributor

There is at most one point per each voxel. Naturally, some voxels will be empty because the pointcloud is not covering the entire 3D space of the voxel grid

Yes, my apologies, a silly mistake on my part, that method wouldn't work, and random downsampling would indeed be the best way to proceed. @taketwo Just as a side note, I do think it would be useful to have a function implemented for random downsampling, since it's a pretty common use case. I personally have defaulted to using cloudCompare when i want to downsample something on the fly. @zubair1502 glad you managed to fix it.

@taketwo
Copy link
Member

taketwo commented Mar 4, 2020

I do think it would be useful to have a function implemented for random downsampling

Agree.

Closing since the question was resolved.

@taketwo taketwo closed this as completed Mar 4, 2020
@taketwo taketwo removed the needs: author reply Specify why not closed/merged yet label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question Type of issue
Projects
None yet
Development

No branches or pull requests

4 participants