-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expose Poisson reconstruction parameters #7430
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
base: main
Are you sure you want to change the base?
Changes from all commits
e8337ab
2576ca2
c1b3d9c
fcf9ab8
33fe4ed
9a29e4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -350,7 +350,9 @@ void pybind_trianglemesh_definitions(py::module &m) { | |||||||
| "This function uses the original implementation by " | ||||||||
| "Kazhdan. See https://github.com/mkazhdan/PoissonRecon", | ||||||||
| "pcd"_a, "depth"_a = 8, "width"_a = 0, "scale"_a = 1.1, | ||||||||
| "linear_fit"_a = false, "n_threads"_a = -1) | ||||||||
| "linear_fit"_a = false, "n_threads"_a = -1, | ||||||||
| "full_depth"_a = 5, "samples_per_node"_a = 1.5f, | ||||||||
| "point_weight"_a = 4.0f) | ||||||||
|
||||||||
| "point_weight"_a = 4.0f) | |
| "point_weight"_a = 4.0f, "confidence"_a = false, | |
| "exact_interpolation"_a = false) |
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.
Fixed!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # - Open3D: www.open3d.org - | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2018-2024 www.open3d.org | ||
| # SPDX-License-Identifier: MIT | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
| import open3d as o3d | ||
| import numpy as np | ||
| import pytest | ||
|
|
||
|
|
||
| def _create_point_cloud(num_points=100): | ||
| """Helper to create a point cloud with normals.""" | ||
| np.random.seed(42) # Fixed seed for reproducible tests | ||
| pcd = o3d.geometry.PointCloud() | ||
| pcd.points = o3d.utility.Vector3dVector(np.random.rand(num_points, 3) - 0.5) | ||
| pcd.normals = o3d.utility.Vector3dVector( | ||
| np.random.rand(num_points, 3) - 0.5) | ||
| pcd.normalize_normals() | ||
| return pcd | ||
|
|
||
|
|
||
| def _assert_valid_mesh(mesh, densities): | ||
| """Helper to validate mesh and densities output.""" | ||
| assert mesh is not None | ||
| assert len(mesh.vertices) > 0 | ||
| assert len(mesh.triangles) > 0 | ||
| assert len(densities) == len(mesh.vertices) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sample_point_cloud(): | ||
| """Fixture that returns a simple point cloud for testing.""" | ||
| return _create_point_cloud() | ||
|
|
||
|
|
||
| def test_poisson_default_parameters(sample_point_cloud): | ||
| """Test Poisson reconstruction with default parameters.""" | ||
| mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson( | ||
| sample_point_cloud, depth=6) | ||
| _assert_valid_mesh(mesh, densities) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("params", [ | ||
| { | ||
| "depth": 6, | ||
| "full_depth": 4, | ||
| "samples_per_node": 2.0, | ||
| "point_weight": 5.0 | ||
| }, | ||
| { | ||
| "depth": 6, | ||
| "full_depth": 3 | ||
| }, | ||
| { | ||
| "depth": 6, | ||
| "full_depth": 5 | ||
| }, | ||
| { | ||
| "depth": 5, | ||
| "samples_per_node": 1.0 | ||
| }, | ||
| { | ||
| "depth": 5, | ||
| "samples_per_node": 3.0 | ||
| }, | ||
| { | ||
| "depth": 5, | ||
| "point_weight": 4.0 | ||
| }, | ||
| { | ||
| "depth": 5, | ||
| "point_weight": 10.0 | ||
| }, | ||
| ]) | ||
| def test_poisson_with_various_parameters(sample_point_cloud, params): | ||
| """Test Poisson reconstruction with various parameter combinations.""" | ||
| mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson( | ||
| sample_point_cloud, **params) | ||
| _assert_valid_mesh(mesh, densities) | ||
|
|
||
|
|
||
| def test_poisson_backward_compatibility(): | ||
| """Test that old API calls still work (backward compatibility).""" | ||
| pcd = _create_point_cloud(num_points=50) | ||
|
|
||
| # Old-style call without new parameters | ||
| mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson( | ||
| pcd, depth=5, scale=1.1, linear_fit=False) | ||
| _assert_valid_mesh(mesh, densities) |
Uh oh!
There was an error while loading. Please reload this page.