import numpy as np use_cuda = True if use_cuda: import cupy as cp to_cpu = cp.asnumpy cp.cuda.set_allocator(cp.cuda.MemoryPool().malloc) else: cp = np to_cpu = lambda x: x import open3d as o3 import transforms3d as trans from probreg import cpd from probreg import callbacks import utils import time source, target = utils.prepare_source_and_target_rigid_3d('bunny.pcd', voxel_size=0.003) source = cp.asarray(source.points, dtype=cp.float32) target = cp.asarray(target.points, dtype=cp.float32) rcpd = cpd.RigidCPD(source, use_cuda=use_cuda) start = time.time() tf_param, _, _ = rcpd.registration(target) elapsed = time.time() - start print("time: ", elapsed) print("result: ", np.rad2deg(t3d.euler.mat2euler(to_cpu(tf_param.rot))), tf_param.scale, to_cpu(tf_param.t))
import numpy as np import transforms3d as t3d from probreg import filterreg from probreg import callbacks import utils source, target = utils.prepare_source_and_target_rigid_3d('cloud_0.pcd', n_random=0, normals=True) cbs = [callbacks.Open3dVisualizerCallback(source, target)] objective_type = 'pt2pl' tf_param, _, _ = filterreg.registration_filterreg( source, target, target.normals, objective_type=objective_type, sigma2=0.01, callbacks=cbs) print("result: ", np.rad2deg(t3d.euler.mat2euler(tf_param.rot)), tf_param.scale, tf_param.t)
import numpy as np import transformations as trans from probreg import filterreg from probreg import features from probreg import callbacks import utils source, target = utils.prepare_source_and_target_rigid_3d( 'bunny.pcd', orientation=np.deg2rad([0.0, 0.0, 80.0]), translation=np.array([0.5, 0.0, 0.0]), n_random=0) cbs = [callbacks.Open3dVisualizerCallback(source, target)] objective_type = 'pt2pt' tf_param, _, _ = filterreg.registration_filterreg( source, target, objective_type=objective_type, sigma2=1000, feature_fn=features.FPFH(), callbacks=cbs) rot = trans.identity_matrix() rot[:3, :3] = tf_param.rot print("result: ", np.rad2deg(trans.euler_from_matrix(rot)), tf_param.scale, tf_param.t)
import numpy as np import transforms3d as t3d from probreg import gmmtree from probreg import callbacks import utils source, target = utils.prepare_source_and_target_rigid_3d('bunny.pcd', n_random=0) cbs = [callbacks.Open3dVisualizerCallback(source, target)] tf_param, _ = gmmtree.registration_gmmtree(source, target, callbacks=cbs) print("result: ", np.rad2deg(t3d.euler.mat2euler(tf_param.rot)), tf_param.scale, tf_param.t)
from timeit import default_timer as timer import numpy as np import open3d as o3 import utils from probreg import cpd from probreg import l2dist_regs from probreg import gmmtree from probreg import filterreg threshold = 0.001 max_iteration = 100 source, target = utils.prepare_source_and_target_rigid_3d( 'bunny.pcd', n_random=0, orientation=np.deg2rad([0.0, 0.0, 10.0])) start = timer() res = o3.pipelines.registration.registration_icp( source, target, 0.5, np.identity(4), o3.pipelines.registration.TransformationEstimationPointToPoint(), o3.pipelines.registration.ICPConvergenceCriteria( max_iteration=max_iteration)) end = timer() print('ICP(Open3D): ', end - start) start = timer() res = cpd.registration_cpd(source, target, maxiter=max_iteration, tol=threshold) end = timer() print('CPD: ', end - start)