-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdal_segmentation.py
67 lines (63 loc) · 1.9 KB
/
pdal_segmentation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This file is meant to generate segmented point coulds as buildings and trees (laz/las)
# expected export format: laz/las file
# Version 1.0.0:
# changes : initial script
# Author: Walid Ghariani
import sys
import pdal
import json
def pdal_seg(infile, filtertype, segmented_pts):
''' Point clouds proccessing pipeline to create a segmented
Args:
infile (str): input laz/las file
segmented_pts (str): output laz/las file of Segmenetation using Approximate Coplanar Filter
'''
pipe_Seg =\
{
"pipeline":[
"./output_lidar/"+infile,
{
"type":"filters.elm",
"threshold":2.0
},
{
"type":"filters.outlier",
"method":"statistical",
"mean_k":8,
"multiplier":2
},
{
"type":"filters."+filtertype
},
{
"type":"filters.hag"
},
{
"type":"filters.range",
"limits":"Classification[1:1]"
},
{
"type":"filters.approximatecoplanar",
"knn":64,
"thresh1":25,
"thresh2":6
},
{
"filename":"./output_lidar/"+segmented_pts,
"extra_dims":"all"
}
]
}
# HAG Segmenetation using Approximate Coplanar Filter
print("-----> Approximate Coplanar Filter Segmentation Processing: In progress")
pipelineSeg = pdal.Pipeline(json.dumps(pipe_Seg))
pipelineSeg.validate()
count = pipelineSeg.execute()
print("-----> Approximate Coplanar Filter Segmentation Processing: Done")
def main() :
infile = sys.argv[1]
filtertype = sys.argv[2]
segmented_pts = sys.argv[3]
pdal_seg(infile, filtertype, segmented_pts)
if __name__ == "__main__":
main()