Skip to content

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

Open
@usccolumbia

Description

@usccolumbia

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions