I need help with my code. We are trying to match 3D-scans of horse saddles with 3D-scans of horses backs, which results in some problems. We are using Open3D and Iterative closest point, we are currently giving it an initial_transformation and puts the saddle quite well on the horse back. But when we run the icp its moving the saddle to much forward. My guess is that the saddle is clipping through the horse back to much with the initial position. Is the a better way to optimise the initial transformation?
def match_saddle(horse_file_path, saddle_file_path):
try:
horse_pcd = load_point_cloud(horse_file_path)
saddle_pcd = load_point_cloud(saddle_file_path)
threshold = 5
# Find the highest y points in both point clouds
highest_y_horse = get_highest_y_point(horse_pcd)
highest_y_saddle = get_highest_y_point(saddle_pcd)
highest_x_saddle = get_highest_x_point(saddle_pcd)
# Calculate the initial transformation
initial_transformation = np.eye(4)
initial_transformation[:3, 3] = [
highest_y_horse[0] - highest_x_saddle[0],
highest_y_horse[1] - highest_y_saddle[1] + 100,
highest_y_horse[2] - highest_y_saddle[2]
]
saddle_pcd_filtered = o3d.geometry.PointCloud()
saddle_pcd_filtered.points = o3d.utility.Vector3dVector(np.asarray(saddle_pcd.points))
icp_result = o3d.pipelines.registration.registration_icp(
saddle_pcd_filtered, horse_pcd, threshold, init = initial_transformation,
estimation_method=o3d.pipelines.registration.TransformationEstimationPointToPlane()
)
saddle_pcd.transform(icp_result.transformation)
o3d.visualization.draw_geometries([horse_pcd, saddle_pcd], window_name=saddle_file_path)
return saddle_file_path
Skriv till Kandidatarbete