kopia lustrzana https://github.com/OpenDroneMap/ODM
Some optimization, exception handling
rodzic
e5bd090ba5
commit
4137f20bd9
|
@ -11,6 +11,7 @@ from opendm.utils import double_quote
|
|||
from opendm import log
|
||||
from opendm import io
|
||||
from opendm import system
|
||||
from opendm.concurrency import get_max_memory
|
||||
|
||||
def get_point_cloud_crs(file):
|
||||
pipeline = pdal.Pipeline(json.dumps([ file ]))
|
||||
|
@ -34,16 +35,18 @@ def reproject_point_cloud(file, out_srs):
|
|||
return out_file
|
||||
|
||||
def reproject_raster(file, out_srs):
|
||||
out_file = io.related_file_path(file, postfix="_reprojected")
|
||||
out_file = io.related_file_path(file, postfix="_reprojected_tmp")
|
||||
kwargs = {
|
||||
'input': double_quote(file),
|
||||
'output': double_quote(out_file),
|
||||
'out_srs': out_srs,
|
||||
'max_memory': get_max_memory()
|
||||
}
|
||||
system.run('gdalwarp '
|
||||
'-t_srs {out_srs} '
|
||||
'{input} '
|
||||
'{output} '.format(**kwargs))
|
||||
'{output} '
|
||||
'--config GDAL_CACHEMAX {max_memory}% '.format(**kwargs))
|
||||
return out_file
|
||||
|
||||
def compute_alignment_matrix(input_laz, align_file, stats_dir):
|
||||
|
@ -69,6 +72,8 @@ def compute_alignment_matrix(input_laz, align_file, stats_dir):
|
|||
return
|
||||
|
||||
to_delete = []
|
||||
|
||||
try:
|
||||
log.ODM_INFO("Align CRS: %s" % align_crs)
|
||||
if input_crs != align_crs:
|
||||
# Reprojection needed
|
||||
|
@ -109,13 +114,12 @@ def compute_alignment_matrix(input_laz, align_file, stats_dir):
|
|||
}, indent=4))
|
||||
|
||||
matrix = np.fromstring(reg['matrix'], dtype=float, sep=' ').reshape((4, 4))
|
||||
|
||||
return matrix
|
||||
finally:
|
||||
for f in to_delete:
|
||||
if os.path.isfile(f):
|
||||
os.unlink(f)
|
||||
|
||||
return matrix
|
||||
|
||||
def transform_point_cloud(input_laz, a_matrix, output_laz):
|
||||
pipe = [
|
||||
input_laz,
|
||||
|
|
|
@ -185,7 +185,12 @@ class ODMGeoreferencingStage(types.ODM_Stage):
|
|||
if alignment_file_exists:
|
||||
os.unlink(tree.odm_georeferencing_alignment_matrix)
|
||||
|
||||
a_matrix = None
|
||||
try:
|
||||
a_matrix = compute_alignment_matrix(tree.odm_georeferencing_model_laz, tree.odm_align_file, stats_dir)
|
||||
except Exception as e:
|
||||
log.ODM_WARNING("Cannot compute alignment matrix: %s" % str(e))
|
||||
|
||||
if a_matrix is not None:
|
||||
log.ODM_INFO("Alignment matrix: %s" % a_matrix)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue