-
Notifications
You must be signed in to change notification settings - Fork 45
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
pointcloud sampling #2696
Comments
Hello, The function If you want the result as numpy array, then you can export all points (before sampling) and sample mask: from meshlib import mrmesh
from meshlib import mrmeshnumpy
# Start from numpy arrays
u, v = np.mgrid[0 : 2 * np.pi : 100j, 0 : np.pi : 100j]
x = np.cos(u) * np.sin(v)
y = np.sin(u) * np.sin(v)
z = np.cos(v)
# Prepare for MeshLib PointCloud
verts = np.stack((x.flatten(), y.flatten(), z.flatten()), axis=-1).reshape(-1, 3)
# Create MeshLib PointCloud from np ndarray
pc = mrmeshnumpy.pointCloudFromPoints(verts)
assert(pc.validPoints.count() == 10000)
# Sample points
samples = mrmesh.pointGridSampling(pc, 0.1)
assert(samples.count() == 1524)
# Convert all points (before downsampling) in numpy array
pts = mrmeshnumpy.toNumpyArray(pc.points)
# Convert sample mask in numpy array of True/False
mrmeshnumpy.getNumpyBitSet(samples) |
Thank you for your suggestion, which has solved my problem. By the way, I want to know if there is a method to downsample the point cloud to a fixed number. for example, after sampling, the number of points in the point cloud is 5000. |
The second parameter in In short, one has to increase As to receiving exactly specified number of samples, we have such option for meshes (see decimation), but not for point clouds yet. |
Hello ,I use the method pointGridSampling to downsample the pointcloud. Which python method can be used to check the number of points in the downsampled point cloud? And how to convert the downsampled point coordinates into numpy array
The text was updated successfully, but these errors were encountered: