| 1 | #!/usr/bin/env python |
||
| 2 | |||
| 3 | """Segmentation using DBSCAN. |
||
| 4 | |||
| 5 | Segments a pointcloud into clusters using a DBSCAN algorithm. |
||
| 6 | |||
| 7 | Usage: |
||
| 8 | dbscan [-r <weight>] [-f <format>] [-o <dir>] <epsilon> <minpoints> <file> |
||
| 9 | |||
| 10 | Options: |
||
| 11 | -r <weight>, --rgb_weight <weight> weight assigned to color space |
||
| 12 | [default 0.0]. |
||
| 13 | -f <format>, --format <format> format of output files [default: las]. |
||
| 14 | -o <dir>, --output_dir <dir> output directory for clusters |
||
| 15 | [default: .]. |
||
| 16 | """ |
||
| 17 | |||
| 18 | from docopt import docopt |
||
| 19 | import sys |
||
| 20 | |||
| 21 | from patty.segmentation import segment_dbscan |
||
| 22 | from patty.utils import load, save |
||
| 23 | |||
| 24 | if __name__ == '__main__': |
||
| 25 | args = docopt(__doc__, sys.argv[1:]) |
||
|
0 ignored issues
–
show
|
|||
| 26 | |||
| 27 | rgb_weight = float(args['--rgb_weight']) |
||
|
0 ignored issues
–
show
The name
rgb_weight does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 28 | eps = float(args['<epsilon>']) |
||
|
0 ignored issues
–
show
The name
eps does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 29 | minpoints = int(args['<minpoints>']) |
||
|
0 ignored issues
–
show
The name
minpoints does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 30 | |||
| 31 | # Kludge to get a proper exception for file not found |
||
| 32 | # (PCL will report "problem parsing header!"). |
||
| 33 | with open(args['<file>']) as _: |
||
| 34 | pc = load(args['<file>']) |
||
|
0 ignored issues
–
show
The name
pc does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 35 | print("%d points" % len(pc)) |
||
| 36 | |||
| 37 | clusters = segment_dbscan(pc, epsilon=eps, minpoints=minpoints, |
||
|
0 ignored issues
–
show
The name
clusters does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 38 | rgb_weight=rgb_weight) |
||
| 39 | |||
| 40 | n_outliers = len(pc) |
||
|
0 ignored issues
–
show
The name
n_outliers does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 41 | for i, cluster in enumerate(clusters): |
||
| 42 | print("%d points in cluster %d" % (len(cluster), i)) |
||
| 43 | filename = '%s/cluster%d.%s' % (args['--output_dir'], i, |
||
| 44 | args['--format']) |
||
| 45 | save(cluster, filename) |
||
| 46 | n_outliers -= len(cluster) |
||
| 47 | |||
| 48 | print("%d outliers" % n_outliers) |
||
| 49 |
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.