Compute point cloud density per cubic foot

240 views Asked by At

What's a good way to compute the points-per-cubic-foot density on a lidar dataset? I'm primarily looking for python based solutions. I'm open to other tools if they are fairly easy to implement.

I have several point clouds (lidar) that I'd like to compare point density on. These are UAV flown lidar over neighborhoods with trees, houses, etc... I have a few different acquisition sources. I want to check the typical point density to prepare them for semantic segmentation purposes (i.e. I'll probably end up reducing everything to the lowest point density for consistency). Some of them came from a vendor that provided the points-per-cubic-foot measure, some did not.

My current python stack is numpy, laspy and/or open3d. I don't want to add more packages unnecessarily.

My point cloud CRS is in US feet, so 1 unit = 1 foot.

Initially I tried loading these to open3d for downsampling via voxelization. Downsampling works, but doesn't tell me the original point density. I had hoped I could convert to one cubic foot voxels then figure out how many points were in each voxel. I didn't see a simple way to get a point count after making voxels with open3d.

My first attempt:

import numpy as np
import open3d as o3d

ply_file = "lidar1.ply"
pcd = o3d.t.io.read_point_cloud(ply_file)
voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(pcd.to_legacy(), voxel_size=1)
# I imagined I could loop through voxels and save how many points are in each
# since each voxel is 1 cubic foot, it's already the points-per-cubic-foot I want.
# Then just take the max, 90th percentile or something like that. 
# I know most voxels will be sparse or empty.

I imagine there are ways only with numpy to get this, which is fine. I'm interested in something reasonably performant and easy to implement. I have a few large point clouds, but don't need an exact number. I'm using laspy to open my las and laz files, which I then convert to open3d as needed.

My backup plan is to downsample via voxelization all point clouds to some value with out good information on the original point density. Not ideal, but I could get by.

0

There are 0 answers