A geometric segmentation pipeline that classifies LiDAR-style point-cloud data into ground, structure, vegetation, and defect-candidate classes, built around the kind of inspection workflow used for bridges, buildings, and other built infrastructure.
Live demo (Streamlit) | Related project: bridge-defect-detector (YOLOv8, 99.1% mAP@0.5)
The pipeline takes a 3D point cloud and segments it in three stages:
- Ground plane removal — RANSAC plane fitting isolates the ground plane so it doesn't interfere with structure/vegetation classification.
- Clustering and classification — DBSCAN clusters the remaining
points, then each cluster is classified as
structureorvegetationusing PCA-based planarity and height heuristics. Flat, vertical, tall clusters (walls, beams, panels) are structure; irregular, lower-planarity clusters are vegetation. - Defect candidate detection — within points already classified as structure, local point density is compared against the surface's overall density (via k-nearest-neighbour distances). Patches that are locally denser than the surrounding surface are flagged as defect candidates, a proxy for things like spalling, corrosion patches, or crack zones that an inspector would want to review.
On the synthetic test scene included in this repo, the pipeline achieves:
| Class | Accuracy |
|---|---|
| Ground | 98.8% |
| Structure | 97.5% |
| Vegetation | 77.3% |
| Defect candidate | 82.5% |
| Overall | 95.5% |
This deliberately uses classical geometric segmentation (RANSAC + DBSCAN + PCA + local density) rather than a trained model like PointNet++ or RandLA-Net. Two reasons:
- It requires no labelled training data and no GPU, which makes it a realistic first stage for an edge or resource-constrained deployment, and it's how a lot of real point-cloud inspection pipelines actually start before a learned model is layered on top.
- It is honest about what was actually built and tested here in the time available, rather than wrapping a pretrained model whose performance on this kind of data wasn't independently verified.
The natural next step, once labelled real-world scan data is available, is to swap the rule-based classifier for a trained segmentation model and compare performance directly against this baseline.
The point cloud used in the demo is synthetically generated
(scripts/generate_sample_cloud.py), simulating a ground plane, a
structure wall, scattered vegetation, and an embedded defect cluster. No
real LiDAR scan was available for this project, so the synthetic scene
exists to demonstrate the pipeline end-to-end with verifiable ground-truth
labels for the accuracy numbers above.
The pipeline itself works unchanged on real point-cloud data. To use a
real scan, load it into a NumPy array of shape (N, 3) and pass it to
segment.run_pipeline() directly, or save it as an .npz file with a
points key and adapt app.py's load_scene() function to read it
instead of calling build_scene().
git clone https://github.com/lakshan-d/point-cloud-segmentation-infra.git
cd point-cloud-segmentation-infra
pip install -r requirements.txt
streamlit run app.pyOpen the local URL Streamlit prints (usually http://localhost:8501).
The sidebar lets you adjust the DBSCAN clustering radius and the defect
density-ratio threshold live and see how the segmentation changes.
cd scripts
python segment.pyThis generates the sample scene, runs the full pipeline, and prints a per-class accuracy report as JSON.
python tests/test_segment.pypoint-cloud-segmentation-infra/
├── app.py # Streamlit dashboard
├── requirements.txt
├── scripts/
│ ├── generate_sample_cloud.py # synthetic scene generator
│ └── segment.py # segmentation pipeline
├── tests/
│ └── test_segment.py
└── README.md
Built as part of a broader portfolio of computer vision and LiDAR projects targeting infrastructure inspection, alongside an MSc dissertation on drone-based autonomous inspection (LiDAR + YOLOv5) and a co-authored IEEE paper on LiDAR-based self-localisation (FNWF Dubai 2024).
Lakshan Divakar | github.com/lakshan-d | linkedin.com/in/lakshan-d