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

How to superimpose unordered point clouds of arbitrary size using open3d #5

Open
usccolumbia opened this issue Mar 3, 2024 · 1 comment

Comments

@usccolumbia
Copy link

usccolumbia commented Mar 3, 2024

as the author pointed out:
Note: This function does not attempt to determine which pairs of points from either cloud correspond. Instead, it infers them from the order of the arrays. (It assumes that the i'th point from X corresponds to the i'th point from x.)

This assumption does not hold for generic point cloud registration such as atom point clouds of crystals.
If you want to do superpose3d for un-ordered points, you'd better try open3d, which I have spent a lot of effort to make it work.

import open3d as o3d
import numpy as np
source = o3d.geometry.PointCloud()
target = o3d.geometry.PointCloud()

np.random.seed(0)
pointset = np.random.rand(10, 3)
source.points = o3d.utility.Vector3dVector(pointset) # Random points

Generate target point cloud

target.points = o3d.utility.Vector3dVector(pointset) # Random points
target.transform([[1, 0, 0, 0.5],
[0, 1, 0., 0.0],
[0, 0.2, 1, 0],
[0, 0, 0, 1]])

Apply ICP registration

threshold = 5
trans_init = np.identity(4) # Initial transformation matrix
reg_p2p = o3d.pipelines.registration.registration_icp(
source, target, threshold, trans_init,
o3d.pipelines.registration.TransformationEstimationPointToPoint(),
o3d.pipelines.registration.ICPConvergenceCriteria(max_iteration=1000))

print("Transformation matrix:")
print(reg_p2p.transformation)

print("Matching points:")
print(np.asarray(reg_p2p.correspondence_set))
print(f"% of match:{reg_p2p.fitness*100}%")
print(reg_p2p.inlier_rmse)

@jewettaij
Copy link
Owner

This is awesome, usccolumbia! I'll post a link to it on the front page.

@jewettaij jewettaij changed the title Warning: severe limitation of superpose3D How to superimpose unordered point clouds of arbitrary size using open3d Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants