factorize opensfm cell

Former-commit-id: ac3d16b3c1
pull/1161/head
edgarriba 2015-11-27 16:51:21 +00:00
rodzic 484ec935aa
commit 77826b8b10
1 zmienionych plików z 21 dodań i 15 usunięć

Wyświetl plik

@ -15,9 +15,8 @@ class ODMOpenSfMCell(ecto.Cell):
params.declare("matching_gps_neighbors", "The application arguments.", 0)
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", [])
inputs.declare("args", "The application arguments.", {})
inputs.declare("photos", "Clusters output. list of ODMPhoto's", [])
outputs.declare("reconstructions", "Clusters output. list of reconstructions", [])
def process(self, inputs, outputs):
@ -27,28 +26,34 @@ class ODMOpenSfMCell(ecto.Cell):
# get inputs
args = self.inputs.args
photos = self.inputs.photos
project_path = io.absolute_path_file(self.inputs.project_path)
project_path = io.absolute_path_file(args['project_path'])
# create file list directory
list_path = io.join_paths(project_path, 'opensfm')
system.mkdir_p(list_path)
if not photos:
log.ODM_ERROR('Not enough photos in photos array to start OpenSfm')
return ecto.QUIT
# create opensfm working directory
opensfm_path = io.join_paths(project_path, 'opensfm')
system.mkdir_p(opensfm_path)
# check if reconstruction was done before
file_list_path = io.join_paths(list_path, 'image_list.txt')
reconstruction_file = io.join_paths(opensfm_path, 'reconstruction.json')
if io.file_exists(file_list_path):
log.ODM_WARNING('Found a valid reconstruction file')
if 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
with open(file_list_path, 'w') as fout:
list_path = io.join_paths(opensfm_path, 'image_list.txt')
with open(list_path, 'w') as fout:
for photo in photos:
fout.write('%s\n' % photo.path_file)
# create config file for OpenSfM
config = [
"use_exif_size: no",
"use_exif_size: %s" % ('no' if not self.params.use_exif_size else 'yes'),
"feature_process_size: %s" % self.params.feature_process_size,
"feature_min_frames: %s" % self.params.feature_min_frames,
"processes: %s" % self.params.processes,
@ -62,7 +67,7 @@ class ODMOpenSfMCell(ecto.Cell):
# Run OpenSfM reconstruction
system.run('PYTHONPATH=%s %s/bin/run_all %s' %
(context.pyopencv_path, context.opensfm_path, list_path))
(context.pyopencv_path, context.opensfm_path, opensfm_path))
# append reconstructions to output
self.outputs.reconstructions = []
@ -84,6 +89,7 @@ class ODMLoadReconstructionCell(ecto.Cell):
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')
@ -117,11 +123,11 @@ class ODMConvertToPMVSCell(ecto.Cell):
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
return ecto.OK
# run converter
system.run('PYTHONPATH=%s %s/bin/export_pmvs %s' %
(context.pyopencv_path, context.opensfm_path, opensfm_path))
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)