def main(): argvs = sys.argv model_num = str(argvs[1]) scene_num = str(argvs[2]) cloud_dir = "/mnt/container-data/remove_plane/" model_path = cloud_dir + model_num + ".ply" model_cloud = o3.read_point_cloud(model_path) scene_path = cloud_dir + scene_num + ".ply" scene_cloud = o3.read_point_cloud(scene_path) rot_in = read_rotation(model_num) model_cloud.transform(rot_in) model_cloud = o3.voxel_down_sample(model_cloud, voxel_size=0.020) scene_cloud = o3.voxel_down_sample(scene_cloud, voxel_size=0.020) # 基準とするpointcloud, 回転させたいpointcloud の順番 cbs = [callbacks.Open3dVisualizerCallback(model_cloud, scene_cloud)] objective_type = 'pt2pt' # 基準とするpointcloud, 回転させたいpointcloud の順番 tf_param, _, _ = filterreg.registration_filterreg( model_cloud, scene_cloud, scene_cloud.normals, objective_type=objective_type, sigma2=sig, callbacks=cbs, maxiter=ter, tol=ol) write_rotation(tf_param, scene_num)
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)