Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No polygons detected in Airborne Lidar Pointclouds #16

Open
TarunSrinivas23 opened this issue Jul 12, 2023 · 1 comment
Open

No polygons detected in Airborne Lidar Pointclouds #16

TarunSrinivas23 opened this issue Jul 12, 2023 · 1 comment

Comments

@TarunSrinivas23
Copy link

Hey all,
I am trying to use this repository for the first time, and followed the Python documentation to test a pointcloud of my own. But I could not get any planes in the output. This might be a kwargs issue, which I feel is more of a trial and error task but do you think that might be causing this issue? In that case, what would be your solution and how do i get to these optimum argument values for alpha, lmax, z_threshold and others?

This is the code i am using and I am also attaching a link to the pointcloud in discussion

import polylidar
import math
import numpy as np
from polylidar import MatrixDouble, Polylidar3D
import laspy
import time
import matplotlib.pyplot as plt
from polylidar.polylidarutil import (generate_test_points, plot_triangles, get_estimated_lmax,
                                     plot_triangle_meshes, get_triangles_from_list, get_colored_planar_segments, plot_polygons)

from polylidar.polylidarutil import (plot_polygons_3d, generate_3d_plane, set_axes_equal, plot_planes_3d,
                                     scale_points, rotation_matrix, apply_rotation)
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Read LAS file
# las_file_path = 'house1.las'
las_file_path = '/home/tarun/Downloads/house1.las'
las_file = laspy.read(las_file_path)

# Extract x, y, and z coordinates from the LAS points
points = np.vstack((las_file.x, las_file.y, las_file.z)).transpose()

polylidar_kwargs = dict(alpha=0.0, lmax=10, min_triangles=20, z_thresh=0.0, norm_thresh_min=0.94)
polylidar = Polylidar3D(**polylidar_kwargs)

points_mat = MatrixDouble(points, copy=False)
t1 = time.time()
mesh, planes, polygons = polylidar.extract_planes_and_polygons(points_mat)
t2 = time.time()
print("Took {:.2f} milliseconds".format((t2 - t1) * 1000))

triangles = np.asarray(mesh.triangles)
fig, ax = plt.subplots(figsize=(10, 10), nrows=1, ncols=1,
                       subplot_kw=dict(projection='3d'))
# plot all triangles
plot_planes_3d(points, triangles, planes, ax)
plot_polygons_3d(points, polygons, ax)
# plot points
ax.scatter(*scale_points(points), c='k', s=0.1)
set_axes_equal(ax)
ax.view_init(elev=15., azim=-35)
plt.show()
print("")

Link to the pointcloud: https://drive.google.com/file/d/1xuPerTlJ4ScAXkhR_WyrzlSHmZ4KAhYZ/view?usp=sharing

@JeremyBYU
Copy link
Owner

Hey @TarunSrinivas23, thanks for checking out the repo. I am pretty busy at the moment but should be able to take a look this weekend. If this is an unorganized point could there will be complications for using Polylidar3D as my paper states. It can work, you just need to make sure that the surface you want extracted is aligned with the z-axis. And of course, like you said, choose the correct parameters for the point distribution. I would check out Section 10 in my paper. Here is some text form it:

Results also illustrate limitations. First, rooftop and ground extraction in Section 9.2 shows that only one plane normal can be extracted from unorganized 3D points clouds. As described in our methods the front-end currently performs 2.5D Delaunay triangulation which requires 3D → 2D projection. This projection is most suitable when the sensing viewpoint and flat surface of interest are aligned, as is for airborne LiDAR point clouds. However this is not a hard requirement as shown with ground detection from the KITTI dataset. We chose 2.5D Delaunay triangulation for its speed, however other methods may be used such as the ball pivot algorithm [41] or Poisson surface reconstruction [40]. These methods created 3D meshes which could then be processed by Polylidar3D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants