kopia lustrzana https://github.com/OpenDroneMap/ODM
commit
ce6c745715
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
3.1.6
|
3.1.7
|
||||||
|
|
|
@ -62,16 +62,47 @@ def build_untwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=
|
||||||
# Run untwine
|
# Run untwine
|
||||||
system.run('untwine --temp_dir "{tmpdir}" {files} --output_dir "{outputdir}"'.format(**kwargs))
|
system.run('untwine --temp_dir "{tmpdir}" {files} --output_dir "{outputdir}"'.format(**kwargs))
|
||||||
|
|
||||||
def build_copc(input_point_cloud_files, output_file):
|
def build_copc(input_point_cloud_files, output_file, convert_rgb_8_to_16=False):
|
||||||
if len(input_point_cloud_files) == 0:
|
if len(input_point_cloud_files) == 0:
|
||||||
logger.ODM_WARNING("Cannot build COPC, no input files")
|
logger.ODM_WARNING("Cannot build COPC, no input files")
|
||||||
return
|
return
|
||||||
|
|
||||||
base_path, ext = os.path.splitext(output_file)
|
base_path, ext = os.path.splitext(output_file)
|
||||||
|
|
||||||
tmpdir = io.related_file_path(base_path, postfix="-tmp")
|
tmpdir = io.related_file_path(base_path, postfix="-tmp")
|
||||||
if os.path.exists(tmpdir):
|
if os.path.exists(tmpdir):
|
||||||
log.ODM_WARNING("Removing previous directory %s" % tmpdir)
|
log.ODM_WARNING("Removing previous directory %s" % tmpdir)
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
|
cleanup = [tmpdir]
|
||||||
|
|
||||||
|
if convert_rgb_8_to_16:
|
||||||
|
tmpdir16 = io.related_file_path(base_path, postfix="-tmp16")
|
||||||
|
if os.path.exists(tmpdir16):
|
||||||
|
log.ODM_WARNING("Removing previous directory %s" % tmpdir16)
|
||||||
|
shutil.rmtree(tmpdir16)
|
||||||
|
os.makedirs(tmpdir16, exist_ok=True)
|
||||||
|
cleanup.append(tmpdir16)
|
||||||
|
|
||||||
|
converted = []
|
||||||
|
ok = True
|
||||||
|
for f in input_point_cloud_files:
|
||||||
|
# Convert 8bit RGB to 16bit RGB (per COPC spec)
|
||||||
|
base = os.path.basename(f)
|
||||||
|
filename, ext = os.path.splitext(base)
|
||||||
|
out_16 = os.path.join(tmpdir16, "%s_16%s" % (filename, ext))
|
||||||
|
try:
|
||||||
|
system.run('pdal translate -i "{input}" -o "{output}" assign '
|
||||||
|
'--filters.assign.value="Red = Red / 255 * 65535" '
|
||||||
|
'--filters.assign.value="Green = Green / 255 * 65535" '
|
||||||
|
'--filters.assign.value="Blue = Blue / 255 * 65535" '.format(input=f, output=out_16))
|
||||||
|
|
||||||
|
converted.append(out_16)
|
||||||
|
except Exception as e:
|
||||||
|
log.ODM_WARNING("Cannot convert point cloud to 16bit RGB, COPC is not going to follow the official spec: %s" % str(e))
|
||||||
|
ok = False
|
||||||
|
break
|
||||||
|
if ok:
|
||||||
|
input_point_cloud_files = converted
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'tmpdir': tmpdir,
|
'tmpdir': tmpdir,
|
||||||
|
@ -82,5 +113,6 @@ def build_copc(input_point_cloud_files, output_file):
|
||||||
# Run untwine
|
# Run untwine
|
||||||
system.run('untwine --temp_dir "{tmpdir}" {files} -o "{output}" --single_file'.format(**kwargs))
|
system.run('untwine --temp_dir "{tmpdir}" {files} -o "{output}" --single_file'.format(**kwargs))
|
||||||
|
|
||||||
if os.path.exists(tmpdir):
|
for d in cleanup:
|
||||||
shutil.rmtree(tmpdir)
|
if os.path.exists(d):
|
||||||
|
shutil.rmtree(d)
|
|
@ -311,4 +311,4 @@ def post_point_cloud_steps(args, tree, rerun=False):
|
||||||
log.ODM_INFO("Creating Cloud Optimized Point Cloud (COPC)")
|
log.ODM_INFO("Creating Cloud Optimized Point Cloud (COPC)")
|
||||||
|
|
||||||
copc_output = io.related_file_path(tree.odm_georeferencing_model_laz, postfix=".copc")
|
copc_output = io.related_file_path(tree.odm_georeferencing_model_laz, postfix=".copc")
|
||||||
entwine.build_copc([tree.odm_georeferencing_model_laz], copc_output)
|
entwine.build_copc([tree.odm_georeferencing_model_laz], copc_output, convert_rgb_8_to_16=True)
|
Ładowanie…
Reference in New Issue