From e80b89a05543281eee0cd0e31e96a7201e3d0a51 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 15 Jun 2022 08:40:34 -0400 Subject: [PATCH] Plug rs_correct --- SuperBuild/CMakeLists.txt | 2 +- opendm/osfm.py | 17 +++++++++++++++-- opendm/remote.py | 1 + opendm/rollingshutter.py | 2 ++ stages/run_opensfm.py | 3 ++- stages/splitmerge.py | 4 +++- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index fc6576b1..3c167127 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -119,7 +119,7 @@ SETUP_EXTERNAL_PROJECT(GFlags ${ODM_GFlags_Version} ${ODM_BUILD_GFlags}) # --------------------------------------------------------------------------------------------- # Ceres Solver # -set(ODM_Ceres_Version 1.10.0) +set(ODM_Ceres_Version 2.0.0) option(ODM_BUILD_Ceres "Force to build Ceres library" OFF) SETUP_EXTERNAL_PROJECT(Ceres ${ODM_Ceres_Version} ${ODM_BUILD_Ceres}) diff --git a/opendm/osfm.py b/opendm/osfm.py index baac66d8..a6d58d1f 100644 --- a/opendm/osfm.py +++ b/opendm/osfm.py @@ -40,15 +40,19 @@ class OSFMContext: return io.file_exists(tracks_file) and io.file_exists(reconstruction_file) - def reconstruct(self, rerun=False): + def create_tracks(self, rerun=False): tracks_file = os.path.join(self.opensfm_project_path, 'tracks.csv') - reconstruction_file = os.path.join(self.opensfm_project_path, 'reconstruction.json') + rs_file = self.path('rs_done.txt') if not io.file_exists(tracks_file) or rerun: self.run('create_tracks') else: log.ODM_WARNING('Found a valid OpenSfM tracks file in: %s' % tracks_file) + def reconstruct(self, rolling_shutter_correct=False, rerun=False): + # TODO: FIX calls from split-merge + + reconstruction_file = os.path.join(self.opensfm_project_path, 'reconstruction.json') if not io.file_exists(reconstruction_file) or rerun: self.run('reconstruct') self.check_merge_partial_reconstructions() @@ -64,6 +68,15 @@ class OSFMContext: "You could also try to increase the --min-num-features parameter." "The program will now exit.") + if rolling_shutter_correct: + rs_file = self.path('rs_done.txt') + + if not io.file_exists(rs_file) or rerun: + self.run('rs_correct --output reconstruction.json --output-tracks tracks.csv') + self.touch(rs_file) + else: + log.ODM_WARNING("Rolling shutter correction already applied") + def check_merge_partial_reconstructions(self): if self.reconstructed(): data = DataSet(self.opensfm_project_path) diff --git a/opendm/remote.py b/opendm/remote.py index 1d45e3bb..9b3b7d26 100644 --- a/opendm/remote.py +++ b/opendm/remote.py @@ -446,6 +446,7 @@ class ReconstructionTask(Task): log.ODM_INFO("Local Reconstruction %s" % octx.name()) log.ODM_INFO("==================================") octx.feature_matching(self.params['rerun']) + octx.create_tracks(self.params['rerun']) octx.reconstruct(self.params['rerun']) def process_remote(self, done): diff --git a/opendm/rollingshutter.py b/opendm/rollingshutter.py index ee5bc370..d134d9bf 100644 --- a/opendm/rollingshutter.py +++ b/opendm/rollingshutter.py @@ -11,6 +11,8 @@ RS_DATABASE = { 'dji fc330': 33, # Phantom 4 'dji fc6310': 33, # Phantom 4 Professional + 'dji fc7203': 20, # Mavic Mini v1 + 'dji fc350': 30, # Inspire 1 'gopro hero4 black': 30 # GoPro Hero 4 Black diff --git a/stages/run_opensfm.py b/stages/run_opensfm.py index cc52318c..6a3dc4a6 100644 --- a/stages/run_opensfm.py +++ b/stages/run_opensfm.py @@ -34,7 +34,8 @@ class ODMOpenSfMStage(types.ODM_Stage): self.update_progress(20) octx.feature_matching(self.rerun()) self.update_progress(30) - octx.reconstruct(self.rerun()) + octx.create_tracks(self.rerun()) + octx.reconstruct(args.rolling_shutter, self.rerun()) octx.extract_cameras(tree.path("cameras.json"), self.rerun()) self.update_progress(70) diff --git a/stages/splitmerge.py b/stages/splitmerge.py index ec279abc..7f0720c5 100644 --- a/stages/splitmerge.py +++ b/stages/splitmerge.py @@ -103,7 +103,9 @@ class ODMSplitStage(types.ODM_Stage): if local_workflow: for sp in submodel_paths: log.ODM_INFO("Reconstructing %s" % sp) - OSFMContext(sp).reconstruct(self.rerun()) + local_sp_octx = OSFMContext(sp) + local_sp_octx.create_tracks(self.rerun()) + local_sp_octx.reconstruct(self.rerun()) else: lre = LocalRemoteExecutor(args.sm_cluster, self.rerun()) lre.set_projects([os.path.abspath(os.path.join(p, "..")) for p in submodel_paths])