1 | #!/usr/bin/env python2.7 |
||
2 | """Registration script. |
||
3 | |||
4 | Usage: |
||
5 | registration.py [-h] [-d <sample>] [-U] [-u <upfile>] [-c <camfile>] <source> <drivemap> <footprint> <output> |
||
6 | |||
7 | Positional arguments: |
||
8 | source Source LAS file |
||
9 | drivemap Target LAS file to map source to |
||
10 | footprint Footprint for the source LAS file |
||
11 | output file to write output LAS to |
||
12 | |||
13 | Options: |
||
14 | -d <sample> Downsample source pointcloud to a percentage of number of points |
||
15 | [default: 0.1]. |
||
16 | -v <voxel> Downsample source pointcloud using voxel filter to speedup ICP |
||
17 | [default: 0.05] |
||
18 | -s <scale> User override for initial scale factor |
||
19 | -U Dont trust the upvector completely and estimate it in |
||
20 | this script, too |
||
21 | -u <upfile> Json file containing the up vector relative to the pointcloud. |
||
22 | -c <camfile> CSV file containing all the camera postionions. [UNIMPLEMENTED] |
||
23 | """ |
||
24 | |||
25 | from __future__ import print_function |
||
26 | from docopt import docopt |
||
27 | |||
28 | import numpy as np |
||
29 | import os |
||
30 | import json |
||
31 | from patty.utils import (load, save, log) |
||
32 | from patty.srs import (set_srs, force_srs) |
||
33 | |||
34 | from patty.registration import ( |
||
35 | coarse_registration, |
||
36 | fine_registration, |
||
37 | initial_registration, |
||
38 | ) |
||
39 | |||
40 | if __name__ == '__main__': |
||
41 | |||
42 | #### |
||
43 | # Parse comamnd line arguments |
||
44 | |||
45 | args = docopt(__doc__) |
||
0 ignored issues
–
show
|
|||
46 | |||
47 | sourcefile = args['<source>'] |
||
0 ignored issues
–
show
The name
sourcefile 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. ![]() |
|||
48 | drivemapfile = args['<drivemap>'] |
||
0 ignored issues
–
show
The name
drivemapfile 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. ![]() |
|||
49 | footprintcsv = args['<footprint>'] |
||
50 | foutLas = args['<output>'] |
||
0 ignored issues
–
show
The name
foutLas 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. ![]() |
|||
51 | up_file = args['-u'] |
||
52 | |||
53 | if args['-U']: |
||
54 | Trust_up = False |
||
55 | else: |
||
56 | Trust_up = True |
||
57 | |||
58 | try: |
||
59 | Downsample = float(args['-d']) |
||
60 | except KeyError: |
||
61 | Downsample = 0.1 |
||
62 | |||
63 | try: |
||
64 | Voxel = float(args['-v']) |
||
65 | except KeyError: |
||
66 | Voxel = 0.05 |
||
67 | |||
68 | try: |
||
69 | Initial_scale = float(args['-s']) |
||
70 | except: |
||
71 | Initial_scale = None |
||
72 | |||
73 | assert os.path.exists(sourcefile), sourcefile + ' does not exist' |
||
74 | assert os.path.exists(drivemapfile), drivemapfile + ' does not exist' |
||
75 | assert os.path.exists(footprintcsv), footprintcsv + ' does not exist' |
||
76 | |||
77 | ##### |
||
78 | # Setup * the low-res drivemap |
||
79 | # * footprint |
||
80 | # * pointcloud |
||
81 | # * up-vector |
||
82 | |||
83 | log("Reading drivemap", drivemapfile) |
||
84 | drivemap = load(drivemapfile) |
||
85 | force_srs(drivemap, srs="EPSG:32633") |
||
86 | |||
87 | log("Reading footprint", footprintcsv) |
||
88 | footprint = load(footprintcsv) |
||
89 | force_srs(footprint, srs="EPSG:32633") |
||
90 | set_srs(footprint, same_as=drivemap) |
||
91 | |||
92 | log("Reading object", sourcefile) |
||
93 | pointcloud = load(sourcefile) |
||
94 | |||
95 | Up = None |
||
96 | try: |
||
97 | with open(up_file) as f: |
||
98 | dic = json.load(f) |
||
99 | Up = np.array(dic['estimatedUpDirection']) |
||
100 | log("Reading up_file", up_file) |
||
101 | except: |
||
102 | log("Cannot parse upfile, skipping") |
||
103 | |||
104 | initial_registration(pointcloud, Up, drivemap, |
||
105 | trust_up=Trust_up, initial_scale=Initial_scale) |
||
106 | save(pointcloud, "initial.las") |
||
107 | center = coarse_registration(pointcloud, drivemap, footprint, Downsample) |
||
108 | save(pointcloud, "coarse.las") |
||
109 | fine_registration(pointcloud, drivemap, center, voxelsize=Voxel) |
||
110 | |||
111 | save(pointcloud, foutLas) |
||
112 |
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.