Commit 655bfd43 authored by Paul Brust's avatar Paul Brust
Browse files

add pauls wall finding

parent 38c7f210
......@@ -22,7 +22,7 @@ def filter_floor(input_data, floor_height, floor_range, error_percentage, offset
return floor_data.loc[floor_data['Z'] > (floor_height + offset - floor_range * error_percentage)]
def do_open3d_struff(input_data, eps, min_points):
def do_open3d_clustering(input_data, eps, min_points):
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(input_data[["X", "Y", "Z"]].to_numpy())
......@@ -37,11 +37,36 @@ def do_open3d_struff(input_data, eps, min_points):
o3d.visualization.draw_geometries([pcd])
def do_open3d_plane_segmentation(input_data):
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,
ransac_n=3,
num_iterations=1000)
cmap = plt.get_cmap("tab20")
walls = []
while len(inliers) > 1000:
print(f"found wall with {len(inliers)} points")
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)
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)
def main():
input_data = pd.read_csv("datasets/Scan_1087.csv")
center = [53.2685, 15.2166, 10.5388]
# do_open3d_struff(input_data, 0.15, 200)
# do_open3d_clustering(input_data, 0.15, 200)
do_open3d_plane_segmentation(input_data)
fig, axs = plt.subplots(2, 2)
floor_heights = get_floors(input_data, axs[0, 0])
......@@ -49,15 +74,16 @@ def main():
floor_range = floor_heights[1] - floor_heights[0]
floor_data = filter_floor(input_data, floor_heights[0], floor_range, error_percentage)
do_open3d_struff(floor_data, 0.2, 100)
do_open3d_plane_segmentation(floor_data)
floor_data.plot.scatter(x="X", y="Y", ax=axs[0, 1], title="floor")
wall_data = filter_floor(input_data, floor_heights[0], floor_range, error_percentage, 1)
do_open3d_struff(wall_data, 0.2, 150)
do_open3d_plane_segmentation(wall_data)
wall_data.plot.scatter(x="X", y="Y", ax=axs[1, 0], title="walls")
ceiling_data = filter_floor(input_data, floor_heights[1], floor_range, error_percentage)
ceiling_data.plot.scatter(x="X", y="Y", ax=axs[1, 1], title="ceiling")
do_open3d_plane_segmentation(ceiling_data)
plt.show()
......
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