kopia lustrzana https://github.com/OpenDroneMap/ODM
refactorize opensfm cell in order to give proper error logs
Former-commit-id: bb28291360
pull/1161/head
rodzic
453cb2d79c
commit
84aeaae91c
|
@ -18,6 +18,7 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
inputs.declare("args", "The application arguments.", {})
|
inputs.declare("args", "The application arguments.", {})
|
||||||
inputs.declare("photos", "Clusters output. list of ODMPhoto's", [])
|
inputs.declare("photos", "Clusters output. list of ODMPhoto's", [])
|
||||||
outputs.declare("reconstructions", "Clusters output. list of reconstructions", [])
|
outputs.declare("reconstructions", "Clusters output. list of reconstructions", [])
|
||||||
|
outputs.declare("reconstruction_path", "The directory to the images to load.", "")
|
||||||
|
|
||||||
def process(self, inputs, outputs):
|
def process(self, inputs, outputs):
|
||||||
|
|
||||||
|
@ -32,19 +33,16 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
log.ODM_ERROR('Not enough photos in photos array to start OpenSfm')
|
log.ODM_ERROR('Not enough photos in photos array to start OpenSfm')
|
||||||
return ecto.QUIT
|
return ecto.QUIT
|
||||||
|
|
||||||
# create opensfm working directory
|
# create working directories
|
||||||
opensfm_path = io.join_paths(project_path, 'opensfm')
|
opensfm_path = io.join_paths(project_path, 'opensfm')
|
||||||
|
pmvs_path = io.join_paths(project_path, 'pmvs')
|
||||||
system.mkdir_p(opensfm_path)
|
system.mkdir_p(opensfm_path)
|
||||||
|
system.mkdir_p(pmvs_path)
|
||||||
|
|
||||||
# check if reconstruction was done before
|
### check if reconstruction was done before
|
||||||
reconstruction_file = io.join_paths(opensfm_path, 'reconstruction.json')
|
reconstruction_file = io.join_paths(opensfm_path, 'reconstruction.json')
|
||||||
|
|
||||||
if io.file_exists(reconstruction_file):
|
if not io.file_exists(reconstruction_file):
|
||||||
log.ODM_WARNING('Found a valid reconstruction file in: %s' %
|
|
||||||
(reconstruction_file))
|
|
||||||
log.ODM_INFO('Running OMD OpenSfm Cell - Finished')
|
|
||||||
return ecto.OK if args['end_with'] != 'opensfm' else ecto.QUIT
|
|
||||||
|
|
||||||
# create file list
|
# create file list
|
||||||
list_path = io.join_paths(opensfm_path, 'image_list.txt')
|
list_path = io.join_paths(opensfm_path, 'image_list.txt')
|
||||||
with open(list_path, 'w') as fout:
|
with open(list_path, 'w') as fout:
|
||||||
|
@ -65,75 +63,36 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
with open(config_filename, 'w') as fout:
|
with open(config_filename, 'w') as fout:
|
||||||
fout.write("\n".join(config))
|
fout.write("\n".join(config))
|
||||||
|
|
||||||
# Run OpenSfM reconstruction
|
# run OpenSfM reconstruction
|
||||||
system.run('PYTHONPATH=%s %s/bin/run_all %s' %
|
system.run('PYTHONPATH=%s %s/bin/run_all %s' %
|
||||||
(context.pyopencv_path, context.opensfm_path, opensfm_path))
|
(context.pyopencv_path, context.opensfm_path, opensfm_path))
|
||||||
|
else:
|
||||||
|
log.ODM_WARNING('Found a valid reconstruction file in: %s' %
|
||||||
|
(reconstruction_file))
|
||||||
|
|
||||||
# append reconstructions to output
|
### check if reconstruction was exported to bundler before
|
||||||
self.outputs.reconstructions = []
|
bundler_file = io.join_paths(opensfm_path, 'bundle_r000.out')
|
||||||
print args['end_with']
|
|
||||||
|
if not io.file_exists(bundler_file):
|
||||||
|
# convert back to bundler's format
|
||||||
|
system.run('PYTHONPATH=%s %s/bin/export_bundler %s' %
|
||||||
|
(context.pyopencv_path, context.opensfm_path, opensfm_path))
|
||||||
|
else:
|
||||||
|
log.ODM_WARNING('Found a valid bundle file in: %s' %
|
||||||
|
(reconstruction_file))
|
||||||
|
|
||||||
|
### check if reconstruction was exported to pmvs before
|
||||||
|
pmvs_file = io.join_paths(pmvs_path, 'recon0/pmvs_options.txt')
|
||||||
|
|
||||||
|
if not io.file_exists(pmvs_file):
|
||||||
|
# run PMVS converter
|
||||||
|
system.run('PYTHONPATH=%s %s/bin/export_pmvs %s --output %s' %
|
||||||
|
(context.pyopencv_path, context.opensfm_path, opensfm_path, pmvs_path))
|
||||||
|
else:
|
||||||
|
log.ODM_WARNING('Found a valid PMVS file in: %s' % pmvs_file)
|
||||||
|
|
||||||
|
# append biggest reconstruction path to output
|
||||||
|
self.outputs.reconstruction_path = io.join_paths(pmvs_path, 'recon0')
|
||||||
|
|
||||||
log.ODM_INFO('Running OMD OpenSfm Cell - Finished')
|
log.ODM_INFO('Running OMD OpenSfm Cell - Finished')
|
||||||
return ecto.OK if args['end_with'] != 'opensfm' else ecto.QUIT
|
return ecto.OK if args['end_with'] != 'opensfm' else ecto.QUIT
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
class ODMLoadReconstructionCell(ecto.Cell):
|
|
||||||
|
|
||||||
def declare_io(self, params, inputs, outputs):
|
|
||||||
inputs.declare("project_path", "The directory to the images to load.", "")
|
|
||||||
inputs.declare("photos", "Clusters output. list of ODMPhoto's", [])
|
|
||||||
outputs.declare("reconstructions", "Clusters output. list of reconstructions", [])
|
|
||||||
|
|
||||||
def process(self, inputs, outputs):
|
|
||||||
log.ODM_INFO('Running OMD Load Reconstruction Cell')
|
|
||||||
#log.ODM_WARNING('TODO: Load Reconstruction to as OO')
|
|
||||||
log.ODM_INFO('Running OMD Load Reconstruction Cell - Finished')
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
class ODMConvertToPMVSCell(ecto.Cell):
|
|
||||||
|
|
||||||
def declare_io(self, params, inputs, outputs):
|
|
||||||
inputs.declare("project_path", "The directory to the images to load.", "")
|
|
||||||
inputs.declare("reconstructions", "The directory to the images to load.", "")
|
|
||||||
outputs.declare("reconstruction_path", "The directory to the images to load.", "")
|
|
||||||
|
|
||||||
def process(self, inputs, outputs):
|
|
||||||
|
|
||||||
log.ODM_INFO('Running OMD Convert to PMVS Cell')
|
|
||||||
|
|
||||||
# get inputs
|
|
||||||
reconstructions = self.inputs.reconstructions
|
|
||||||
project_path = io.absolute_path_file(self.inputs.project_path)
|
|
||||||
|
|
||||||
# define projects location
|
|
||||||
pmvs_path = io.join_paths(project_path, 'pmvs')
|
|
||||||
opensfm_path = io.join_paths(project_path, 'opensfm')
|
|
||||||
reconstruction_path = io.join_paths(pmvs_path, 'recon0')
|
|
||||||
pmvs_options_path = io.join_paths(reconstruction_path, 'pmvs_options.txt')
|
|
||||||
|
|
||||||
# appends created project path to output
|
|
||||||
self.outputs.reconstruction_path = reconstruction_path
|
|
||||||
|
|
||||||
if io.file_exists(pmvs_options_path):
|
|
||||||
log.ODM_WARNING('Found a valid pmvs options file')
|
|
||||||
log.ODM_INFO('Running OMD Convert to PMVS Cell - Finished')
|
|
||||||
return ecto.OK
|
|
||||||
|
|
||||||
# run converter
|
|
||||||
system.run('PYTHONPATH=%s %s/bin/export_pmvs %s --output %s' %
|
|
||||||
(context.pyopencv_path, context.opensfm_path, opensfm_path, pmvs_path))
|
|
||||||
|
|
||||||
if io.file_exists(pmvs_options_path):
|
|
||||||
log.ODM_DEBUG('PMVS options file created to: %s' % pmvs_options_path)
|
|
||||||
else:
|
|
||||||
log.ODM_ERROR('Something went wrong when exporting to PMVS')
|
|
||||||
return
|
|
||||||
|
|
||||||
log.ODM_INFO('Running OMD Convert to PMVS Cell - Finished')
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue