Commit fd014af1 authored by Paul Brust's avatar Paul Brust
Browse files

add bounding boxes

parent 655bfd43
......@@ -37,7 +37,7 @@ def do_open3d_clustering(input_data, eps, min_points):
o3d.visualization.draw_geometries([pcd])
def do_open3d_plane_segmentation(input_data):
def do_open3d_plane_segmentation(input_data, show_bounding_boxes=True, show_bounding_hulls=False):
rest = o3d.geometry.PointCloud()
rest.points = o3d.utility.Vector3dVector(input_data[["X", "Y", "Z"]].to_numpy())
plane_model, inliers = rest.segment_plane(distance_threshold=0.05,
......@@ -50,15 +50,30 @@ def do_open3d_plane_segmentation(input_data):
inlier_cloud = rest.select_by_index(inliers)
walls.append(inlier_cloud)
rest = rest.select_by_index(inliers, invert=True)
# o3d.visualization.draw_geometries([inlier_cloud, outlier_cloud])
plane_model, inliers = rest.segment_plane(distance_threshold=0.02,
ransac_n=3,
num_iterations=1000)
hulls = []
bounding_boxes = []
for i in range(len(walls)):
walls[i].paint_uniform_color(list(cmap(i / len(walls)))[:3])
print(len(walls))
o3d.visualization.draw_geometries(walls)
if show_bounding_boxes:
bounding_box = walls[i].get_oriented_bounding_box()
bounding_box.color = (list(cmap(i / len(walls)))[:3])
bounding_boxes.append(bounding_box)
if show_bounding_hulls:
hull, _ = walls[i].compute_convex_hull()
hull_ls = o3d.geometry.LineSet.create_from_triangle_mesh(hull)
hull_ls.paint_uniform_color(list(cmap(i / len(walls)))[:3])
hulls.append(hull_ls)
print(f"number of elements found: {len(walls)}")
if show_bounding_hulls:
o3d.visualization.draw_geometries([*walls, *hulls])
if show_bounding_boxes:
o3d.visualization.draw_geometries([*walls, *bounding_boxes])
def main():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment