isl-org / Open3D

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

PoissonRecon output should not depend on 'width' param if 'depth' is given #5842

Open chanyeong-jeong opened 1 year ago

chanyeong-jeong commented 1 year ago

Checklist

Describe the issue

Readme file from original PoissonRecon repo and the release documentation of open3d says that --width param is ignored if --depth is specified. However, according to this issue, the open3d porting is highly assumed to be responsible for the --width inconsistency as the original C++ code made reproducible mesh regardless of --width value (with --depth specified, obviously).

Steps to reproduce the bug

def test_min_num_points(depth, width, scale):
    for i in range(10, 0, -1):
        sampled_pcl = o3d.geometry.PointCloud()
        sampled_pcl.points = o3d.utility.Vector3dVector(np.arange(3 * i).reshape((-1, 3)))
        sampled_pcl.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(
            radius=50, max_nn=100))
        try:
            (
                poisson_mesh,
                densities,
            ) = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(
                sampled_pcl,
                depth=depth,
                width=width,
                scale=scale,
                linear_fit=True,
                n_threads=-1)
        except Exception as e:
            print("Exception message:", e)
            print("Number of input points:", i)
            return

>>> test_min_num_points(7, 5, 1)

>>> test_min_num_points(7, 0, 1)

Error message

>>> test_min_num_points(7, 5, 1)
Exception message: [Open3D Error] (void open3d::geometry::poisson::Execute(const open3d::geometry::PointCloud&, std::shared_ptr<open3d::geometry::TriangleMesh>&, std::vector<double>&, int, float, float, bool, UIntPack<CSignatures ...>) [with Real = float; SampleData = {}; unsigned int ...FEMSigs = {5, 5, 5}]) /root/Open3D/cpp/open3d/geometry/SurfaceReconstructionPoisson.cpp:519: depth (=1) has to be >= 2

Number of input points: 4

>>> test_min_num_points(7, 0, 1)
[WARNING] /root/Open3D/build/poisson/src/ext_poisson/PoissonRecon/Src/FEMTree.Initialize.inl (Line 192)
          Initialize
          Found out-of-bound points: 1
[WARNING] /root/Open3D/build/poisson/src/ext_poisson/PoissonRecon/Src/FEMTree.Initialize.inl (Line 192)
          Initialize
          Found out-of-bound points: 1
[WARNING] /root/Open3D/build/poisson/src/ext_poisson/PoissonRecon/Src/FEMTree.Initialize.inl (Line 192)
          Initialize
          Found out-of-bound points: 1
[WARNING] /root/Open3D/build/poisson/src/ext_poisson/PoissonRecon/Src/FEMTree.Initialize.inl (Line 192)
          Initialize
          Found out-of-bound points: 1
Segmentation fault (core dumped)
**Python interpreter crashes**

Expected behavior

Triangle mesh created from o3d.geometry.TriangleMesh.create_from_point_cloud_poisson should yield identical output for various width value as long as depth param is specified.

Open3D, Python and System information

- Operating system: Ubuntu 20.04
- Python version: Python 3.8.13
- Open3D version: 0.16.0
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: pip

Additional information

No response

spelufo commented 5 months ago

Reading the code it looks to me that the problem is that Execute calls GetBoundingBoxXForm which computes the depth and xForm correctly from the width but only xForm is passed back to Execute. The rest of the code in Execute uses the original depth (the default value of 8 if not specified). That mismatch may be the problem.