From 12cf668ba2b61e85ddbc486321398bc4197879e2 Mon Sep 17 00:00:00 2001 From: Mihai Date: Thu, 19 May 2022 09:04:57 +0200 Subject: [PATCH] add sharpness/compoleteness option and multiresolution sublevel options for latest version of OpenMVS changes --- opendm/config.py | 15 +++++++++++++++ stages/openmvs.py | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index 8b4d8dcf..1efb5e1b 100755 --- a/opendm/config.py +++ b/opendm/config.py @@ -395,6 +395,21 @@ def config(argv=None, parser=None): help='Improve the accuracy of the point cloud by computing geometrically consistent depthmaps. This increases processing time, but can improve results in urban scenes. ' 'Default: %(default)s') + parser.add_argument('--pc-sharp', + action=StoreTrue, + nargs=0, + default=False, + help='Improve the accuracy of the point cloud by applying filters to sharpen the pointcloud, but reduces the completeness of the reconstruction. ' + 'Default: %(default)s') + + parser.add_argument('--pc-subreslevel', + metavar='', + action=StoreValue, + default=2, + type=int, + help=('The number of lower resolutions to process before estimating output resolution depthmap. ' + 'Default: %(default)s')) + parser.add_argument('--smrf-scalar', metavar='', action=StoreValue, diff --git a/stages/openmvs.py b/stages/openmvs.py index 6594c158..85435604 100644 --- a/stages/openmvs.py +++ b/stages/openmvs.py @@ -59,13 +59,16 @@ class ODMOpenMVSStage(types.ODM_Stage): log.ODM_INFO("Estimating depthmaps") number_views_fuse = 2 + densify_ini_file = os.path.join(tree.openmvs, 'Densify.ini') config = [ " --resolution-level %s" % int(resolution_level), + '--dense-config-file "%s"' % densify_ini_file, "--min-resolution %s" % depthmap_resolution, "--max-resolution %s" % int(outputs['undist_image_max_size']), "--max-threads %s" % args.max_concurrency, "--number-views-fuse %s" % number_views_fuse, + "--sub-resolution-levels %s" % args.pc_subreslevel, '-w "%s"' % depthmaps_dir, "-v 0" ] @@ -73,7 +76,7 @@ class ODMOpenMVSStage(types.ODM_Stage): gpu_config = [] if not has_gpu(): - gpu_config.append("--cuda-device -1") + gpu_config.append("--cuda-device -2") if args.pc_tile: config.append("--fusion-mode 1") @@ -81,6 +84,13 @@ class ODMOpenMVSStage(types.ODM_Stage): if not args.pc_geometric: config.append("--geometric-iters 0") + if args.pc_sharp: + with open(densify_ini_file, 'w+') as f: + f.write("Optimize = 7\n") + else: + with open(densify_ini_file, 'w+') as f: + f.write("Optimize = 3\n") + def run_densify(): system.run('"%s" "%s" %s' % (context.omvs_densify_path, openmvs_scene_file, @@ -93,7 +103,7 @@ class ODMOpenMVSStage(types.ODM_Stage): # try to run it again without GPU if e.errorCode == 1 and len(gpu_config) == 0: log.ODM_WARNING("OpenMVS failed with GPU, is your graphics card driver up to date? Falling back to CPU.") - gpu_config.append("--cuda-device -1") + gpu_config.append("--cuda-device -2") run_densify() else: raise e