From 0a5c938238c52f87acc9cfd42bc96cd7ab291300 Mon Sep 17 00:00:00 2001 From: Stephen Mather Date: Sun, 2 Dec 2018 17:45:26 +0000 Subject: [PATCH] mve over smvs Former-commit-id: 8e3a01fbb77eca68785ed6ec04580a7f8a5dcbdc --- README.md | 2 +- SuperBuild/CMakeLists.txt | 24 +++++++++---------- opendm/config.py | 2 +- opendm/context.py | 6 ++--- opendm/types.py | 8 +++---- run.py | 2 +- scripts/{smvs.py => mve.py} | 44 +++++++++++++++++------------------ scripts/odm_app.py | 30 ++++++++++-------------- scripts/odm_georeferencing.py | 2 +- scripts/odm_meshing.py | 2 +- 10 files changed, 58 insertions(+), 64 deletions(-) rename scripts/{smvs.py => mve.py} (74%) diff --git a/README.md b/README.md index 98ad037a..98d4f0a6 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ or python run.py --rerun-from odm_meshing project-name -The options for rerunning are: 'resize', 'opensfm', 'slam', 'smvs', 'odm_meshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto' +The options for rerunning are: 'resize', 'opensfm', 'slam', 'mve', 'odm_meshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto' ### View Results diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 940ff9dd..b2a37142 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -141,17 +141,17 @@ externalproject_add(mve INSTALL_COMMAND "" ) -externalproject_add(smvs - DEPENDS mve - GIT_REPOSITORY https://github.com/flanggut/smvs.git - GIT_TAG 6a7d0c095aa66ab98c5b285c2bc04e34d8993353 - UPDATE_COMMAND "" - SOURCE_DIR ${SB_SOURCE_DIR}/elibs/smvs - CONFIGURE_COMMAND "" - BUILD_IN_SOURCE 1 - BUILD_COMMAND make - INSTALL_COMMAND "" -) +#externalproject_add(smvs +# DEPENDS mve +# GIT_REPOSITORY https://github.com/flanggut/smvs.git +# GIT_TAG 6a7d0c095aa66ab98c5b285c2bc04e34d8993353 +# UPDATE_COMMAND "" +# SOURCE_DIR ${SB_SOURCE_DIR}/elibs/smvs +# CONFIGURE_COMMAND "" +# BUILD_IN_SOURCE 1 +# BUILD_COMMAND make +# INSTALL_COMMAND "" +#) externalproject_add(poissonrecon GIT_REPOSITORY https://github.com/mkazhdan/PoissonRecon.git @@ -182,4 +182,4 @@ externalproject_add(dem2points BUILD_IN_SOURCE 1 BUILD_COMMAND make INSTALL_COMMAND "" -) \ No newline at end of file +) diff --git a/opendm/config.py b/opendm/config.py index 67698383..2fdb0e6c 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -7,7 +7,7 @@ from appsettings import SettingsParser import sys # parse arguments -processopts = ['dataset', 'opensfm', 'slam', 'smvs', +processopts = ['dataset', 'opensfm', 'slam', 'mve', 'odm_meshing', 'odm_25dmeshing', 'mvs_texturing', 'odm_georeferencing', 'odm_dem', 'odm_orthophoto'] diff --git a/opendm/context.py b/opendm/context.py index 53edb9d8..5323ca33 100644 --- a/opendm/context.py +++ b/opendm/context.py @@ -23,15 +23,15 @@ ccd_widths_path = os.path.join(opensfm_path, 'opensfm/data/sensor_data.json') # define orb_slam2 path orb_slam2_path = os.path.join(superbuild_path, "src/orb_slam2") -# define smvs join_paths +# define mve join_paths makescene_path = os.path.join(superbuild_path, 'src', 'elibs', 'mve', 'apps', 'makescene', 'makescene') #TODO: don't install in source -smvs_path = os.path.join(superbuild_path, 'src', 'elibs', 'smvs', 'app', 'smvsrecon') +mve_path = os.path.join(superbuild_path, 'src', 'elibs', 'mve', 'app', 'dmrecon', 'dmrecon') +mve_path_pc = os.path.join(superbuild_path, 'src', 'elibs', 'mve', 'app', 'scene2pset', 'scene2pset') poisson_recon_path = os.path.join(superbuild_path, 'src', 'PoissonRecon', 'Bin', 'Linux', 'PoissonRecon') dem2mesh_path = os.path.join(superbuild_path, 'src', 'dem2mesh', 'dem2mesh') dem2points_path = os.path.join(superbuild_path, 'src', 'dem2points', 'dem2points') - # define mvstex path mvstex_path = os.path.join(superbuild_path, "install/bin/texrecon") diff --git a/opendm/types.py b/opendm/types.py index 418d128c..1b566380 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -340,7 +340,7 @@ class ODM_Tree(object): # whole reconstruction process. self.dataset_raw = io.join_paths(self.root_path, 'images') self.opensfm = io.join_paths(self.root_path, 'opensfm') - self.smvs = io.join_paths(self.root_path, 'smvs') + self.mve = io.join_paths(self.root_path, 'mve') self.odm_meshing = io.join_paths(self.root_path, 'odm_meshing') self.odm_texturing = io.join_paths(self.root_path, 'odm_texturing') self.odm_25dtexturing = io.join_paths(self.root_path, 'odm_texturing_25d') @@ -365,12 +365,12 @@ class ODM_Tree(object): self.opensfm_model = io.join_paths(self.opensfm, 'depthmaps/merged.ply') self.opensfm_transformation = io.join_paths(self.opensfm, 'geocoords_transformation.txt') - # smvs - self.smvs_model = io.join_paths(self.smvs, 'smvs_dense_point_cloud.ply') + # mve + self.mve_model = io.join_paths(self.mve, 'mve_dense_point_cloud.ply') self.mve_path = io.join_paths(self.opensfm, 'mve') self.mve_image_list = io.join_paths(self.mve_path, 'list.txt') self.mve_bundle = io.join_paths(self.mve_path, 'bundle/bundle.out') - self.mve_views = io.join_paths(self.smvs, 'views') + self.mve_views = io.join_paths(self.mve, 'views') # odm_meshing self.odm_mesh = io.join_paths(self.odm_meshing, 'odm_mesh.ply') diff --git a/run.py b/run.py index 401908be..d2d2dc77 100644 --- a/run.py +++ b/run.py @@ -33,7 +33,7 @@ if __name__ == '__main__': + args.project_path + "/odm_orthophoto " + args.project_path + "/odm_texturing " + args.project_path + "/opensfm " - + args.project_path + "/smvs") + + args.project_path + "/mve") # create an instance of my App BlackBox # internally configure all tasks diff --git a/scripts/smvs.py b/scripts/mve.py similarity index 74% rename from scripts/smvs.py rename to scripts/mve.py index 2ce9f58f..a440430a 100644 --- a/scripts/smvs.py +++ b/scripts/mve.py @@ -6,7 +6,7 @@ from opendm import system from opendm import context -class ODMSmvsCell(ecto.Cell): +class ODMMveCell(ecto.Cell): def declare_params(self, params): params.declare("threads", "max number of threads", context.num_cores) params.declare("alpha", "Regularization parameter", 1) @@ -27,7 +27,7 @@ class ODMSmvsCell(ecto.Cell): # Benchmarking start_time = system.now_raw() - log.ODM_INFO('Running SMVS Cell') + log.ODM_INFO('Running MVE Cell') # get inputs tree = inputs.tree @@ -36,18 +36,18 @@ class ODMSmvsCell(ecto.Cell): photos = reconstruction.photos if not photos: - log.ODM_ERROR('Not enough photos in photos array to start SMVS') + log.ODM_ERROR('Not enough photos in photos array to start MVE') return ecto.QUIT # check if we rerun cell or not rerun_cell = (args.rerun is not None and - args.rerun == 'smvs') or \ + args.rerun == 'mve') or \ (args.rerun_all) or \ (args.rerun_from is not None and - 'smvs' in args.rerun_from) + 'mve' in args.rerun_from) # check if reconstruction was done before - if not io.file_exists(tree.smvs_model) or rerun_cell: + if not io.file_exists(tree.mve_model) or rerun_cell: # cleanup if a rerun if io.dir_exists(tree.mve_path) and rerun_cell: shutil.rmtree(tree.mve_path) @@ -62,12 +62,12 @@ class ODMSmvsCell(ecto.Cell): # mve makescene wants the output directory # to not exists before executing it (otherwise it # will prompt the user for confirmation) - if io.dir_exists(tree.smvs): - shutil.rmtree(tree.smvs) + if io.dir_exists(tree.mve): + shutil.rmtree(tree.mve) # run mve makescene if not io.dir_exists(tree.mve_views): - system.run('%s %s %s' % (context.makescene_path, tree.mve_path, tree.smvs)) + system.run('%s %s %s' % (context.makescene_path, tree.mve_path, tree.mve)) # config config = [ @@ -81,26 +81,26 @@ class ODMSmvsCell(ecto.Cell): "--force" if rerun_cell else '' ] - # run smvs - system.run('%s %s %s' % (context.smvs_path, ' '.join(config), tree.smvs)) + # run mve + system.run('%s %s %s' % (context.mve_path, ' '.join(config), tree.mve)) # find and rename the output file for simplicity - smvs_files = glob.glob(os.path.join(tree.smvs, 'smvs-*')) - smvs_files.sort(key=os.path.getmtime) # sort by last modified date - if len(smvs_files) > 0: - old_file = smvs_files[-1] - if not (io.rename_file(old_file, tree.smvs_model)): + mve_files = glob.glob(os.path.join(tree.mve, 'mve-*')) + mve_files.sort(key=os.path.getmtime) # sort by last modified date + if len(mve_files) > 0: + old_file = mve_files[-1] + if not (io.rename_file(old_file, tree.mve_model)): log.ODM_WARNING("File %s does not exist, cannot be renamed. " % old_file) else: - log.ODM_WARNING("Cannot find a valid point cloud (smvs-XX.ply) in %s. Check the console output for errors." % tree.smvs) + log.ODM_WARNING("Cannot find a valid point cloud (mve-XX.ply) in %s. Check the console output for errors." % tree.mve) else: - log.ODM_WARNING('Found a valid SMVS reconstruction file in: %s' % - tree.smvs_model) + log.ODM_WARNING('Found a valid MVE reconstruction file in: %s' % + tree.mve_model) outputs.reconstruction = reconstruction if args.time: - system.benchmark(start_time, tree.benchmarking, 'SMVS') + system.benchmark(start_time, tree.benchmarking, 'MVE') - log.ODM_INFO('Running ODM SMVS Cell - Finished') - return ecto.OK if args.end_with != 'smvs' else ecto.QUIT + log.ODM_INFO('Running ODM MVE Cell - Finished') + return ecto.OK if args.end_with != 'mve' else ecto.QUIT diff --git a/scripts/odm_app.py b/scripts/odm_app.py index 6d9794b6..81248c23 100644 --- a/scripts/odm_app.py +++ b/scripts/odm_app.py @@ -8,7 +8,7 @@ from opendm import system from dataset import ODMLoadDatasetCell from run_opensfm import ODMOpenSfMCell -from smvs import ODMSmvsCell +from mve import ODMMvsCell from odm_slam import ODMSlamCell from odm_meshing import ODMeshingCell from mvstex import ODMMvsTexCell @@ -49,13 +49,7 @@ class ODMApp(ecto.BlackBox): fixed_camera_params=p.args.use_fixed_camera_params, hybrid_bundle_adjustment=p.args.use_hybrid_bundle_adjustment), 'slam': ODMSlamCell(), - 'smvs': ODMSmvsCell(alpha=p.args.smvs_alpha, - max_pixels=p.args.depthmap_resolution*p.args.depthmap_resolution, - threads=p.args.max_concurrency, - output_scale=p.args.smvs_output_scale, - shading=p.args.smvs_enable_shading, - gamma_srgb=p.args.smvs_gamma_srgb, - verbose=p.args.verbose), + 'mve': ODMMveCell(), 'meshing': ODMeshingCell(max_vertex=p.args.mesh_size, oct_tree=p.args.mesh_octree_depth, samples=p.args.mesh_samples, @@ -124,16 +118,16 @@ class ODMApp(ecto.BlackBox): self.args[:] >> self.meshing['args'], self.opensfm['reconstruction'] >> self.meshing['reconstruction']] else: - # run smvs + # run mve - connections += [self.tree[:] >> self.smvs['tree'], - self.args[:] >> self.smvs['args'], - self.opensfm['reconstruction'] >> self.smvs['reconstruction']] + connections += [self.tree[:] >> self.mve['tree'], + self.args[:] >> self.mve['args'], + self.opensfm['reconstruction'] >> self.mve['reconstruction']] - # create odm mesh from smvs point cloud + # create odm mesh from mve point cloud connections += [self.tree[:] >> self.meshing['tree'], self.args[:] >> self.meshing['args'], - self.smvs['reconstruction'] >> self.meshing['reconstruction']] + self.mve['reconstruction'] >> self.meshing['reconstruction']] # create odm texture connections += [self.tree[:] >> self.texturing['tree'], @@ -164,14 +158,14 @@ class ODMApp(ecto.BlackBox): connections += [self.tree[:] >> self.slam['tree'], self.args[:] >> self.slam['args']] - connections += [self.tree[:] >> self.smvs['tree'], - self.args[:] >> self.smvs['args'], - self.slam['reconstruction'] >> self.smvs['reconstruction']] + connections += [self.tree[:] >> self.mve['tree'], + self.args[:] >> self.mve['args'], + self.slam['reconstruction'] >> self.mve['reconstruction']] # create odm mesh connections += [self.tree[:] >> self.meshing['tree'], self.args[:] >> self.meshing['args'], - self.smvs['reconstruction'] >> self.meshing['reconstruction']] + self.mve['reconstruction'] >> self.meshing['reconstruction']] # create odm texture connections += [self.tree[:] >> self.texturing['tree'], diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index c2cb2b9d..e702b518 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -99,7 +99,7 @@ class ODMGeoreferencingCell(ecto.Cell): elif args.use_opensfm_dense: kwargs['pc'] = tree.opensfm_model else: - kwargs['pc'] = tree.smvs_model + kwargs['pc'] = tree.mve_model if transformPointCloud: kwargs['pc_params'] = '-inputPointCloudFile {pc} -outputPointCloudFile {pc_geo}'.format(**kwargs) diff --git a/scripts/odm_meshing.py b/scripts/odm_meshing.py index 0ff6bf38..aa19dbc2 100644 --- a/scripts/odm_meshing.py +++ b/scripts/odm_meshing.py @@ -49,7 +49,7 @@ class ODMeshingCell(ecto.Cell): (args.rerun_from is not None and 'odm_meshing' in args.rerun_from) - infile = tree.smvs_model + infile = tree.mve_model if args.fast_orthophoto: infile = os.path.join(tree.opensfm, 'reconstruction.ply') elif args.use_opensfm_dense: