isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.41k stars 2.3k forks source link

What is the role of min_bound and max_bound when voxel_down_sample_and_trace?It doesn't seem to work. #6318

Open star379814385 opened 1 year ago

star379814385 commented 1 year ago

Checklist

Describe the issue

Hello,there is a question.What is the role of min_bound and max_bound when voxel_down_sample_and_trace? This should be by controlling the sampling range of the point cloud, so as to control the number of downsampled point clouds, right? But that doesn't seem to be the case in my project, and I'm not sure if this is a bug. I will reduce the doubts to the following example, why are downpcd2 and downpcd3 the same number of points?###

Steps to reproduce the bug

import numpy as np
import open3d as o3d

pcd = o3d.geometry.PointCloud()
x = np.linspace(-1, 1, 50)
y = np.linspace(-1, 1, 50)
points = np.stack(np.meshgrid(x, y), axis=-1).reshape((-1, 2))
points = np.concatenate([points, np.zeros((points.shape[0], 1))], axis=-1)
pcd.points = o3d.utility.Vector3dVector(points)
# o3d.io.write_point_cloud("ori.pcd", pcd)

voxel_size = 0.5
# down_pcd1 = pcd.voxel_down_sample(voxel_size=voxel_size)
# o3d.io.write_point_cloud("down1.pcd", down_pcd1)

down_pcd2, _, _ = pcd.voxel_down_sample_and_trace(
    voxel_size=voxel_size,
    min_bound=pcd.get_min_bound(),
    max_bound=pcd.get_max_bound(),
)
# o3d.io.write_point_cloud("down2.pcd", down_pcd2)
print(len(down_pcd2.points)) # 25

down_pcd3, _, _ = pcd.voxel_down_sample_and_trace(
    voxel_size=voxel_size,
    min_bound=pcd.get_min_bound(),
    max_bound=pcd.get_min_bound() + voxel_size - 0.001,
)
# o3d.io.write_point_cloud("down3.pcd", down_pcd3)
print(len(down_pcd3.points))  # 25

Error message

none

Expected behavior

Controls the extent of the point cloud that is downsampled.

Open3D, Python and System information

- Operating system: Windows 10 64-bit
- Python version: Python 3.8
- Open3D version: output from python: 0.15.1, 0.17.0
- System architecture: arm64
- Is this a remote workstation?: no
- How did you install Open3D?: pip
- Compiler version (if built from source): no

Additional information

none

theNded commented 1 year ago

The interface may sound confusing, but the boundary is mainly for a sanity check to decide whether the voxel size is too small. You may first crop a point cloud using crop before downsampling