2015-11-30 15:54:55 +00:00
|
|
|
import ecto
|
|
|
|
|
|
|
|
from opendm import log
|
|
|
|
from opendm import io
|
|
|
|
from opendm import system
|
|
|
|
from opendm import context
|
|
|
|
|
|
|
|
|
2016-02-26 18:50:12 +00:00
|
|
|
class ODMTexturingCell(ecto.Cell):
|
2015-12-10 11:01:41 +00:00
|
|
|
def declare_params(self, params):
|
|
|
|
params.declare("resize", 'resizes images by the largest side', 2400)
|
|
|
|
params.declare("resolution", 'The resolution of the output textures. Must be '
|
2016-02-26 18:50:12 +00:00
|
|
|
'greater than textureWithSize.', 4096)
|
2015-12-10 11:01:41 +00:00
|
|
|
params.declare("size", 'The resolution to rescale the images performing '
|
2016-02-26 18:50:12 +00:00
|
|
|
'the texturing.', 3600)
|
2015-12-10 11:01:41 +00:00
|
|
|
|
2015-11-30 15:54:55 +00:00
|
|
|
def declare_io(self, params, inputs, outputs):
|
2015-12-10 11:01:41 +00:00
|
|
|
inputs.declare("tree", "Struct with paths", [])
|
2015-11-30 15:54:55 +00:00
|
|
|
inputs.declare("args", "The application arguments.", {})
|
2015-12-10 11:01:41 +00:00
|
|
|
inputs.declare("reconstruction", "Clusters output. list of ODMReconstructions", [])
|
|
|
|
outputs.declare("reconstruction", "Clusters output. list of ODMReconstructions", [])
|
2015-11-30 15:54:55 +00:00
|
|
|
|
|
|
|
def process(self, inputs, outputs):
|
2016-02-26 18:50:12 +00:00
|
|
|
|
2016-02-29 14:45:00 +00:00
|
|
|
# Benchmarking
|
|
|
|
start_time = system.now_raw()
|
|
|
|
|
2016-03-08 18:26:58 +00:00
|
|
|
log.ODM_INFO('Running ODM Texturing Cell')
|
2015-11-30 15:54:55 +00:00
|
|
|
|
|
|
|
# get inputs
|
|
|
|
args = self.inputs.args
|
2015-12-10 11:01:41 +00:00
|
|
|
tree = self.inputs.tree
|
2015-11-30 15:54:55 +00:00
|
|
|
|
|
|
|
# define paths and create working directories
|
2015-12-10 11:01:41 +00:00
|
|
|
system.mkdir_p(tree.odm_texturing)
|
2015-11-30 15:54:55 +00:00
|
|
|
|
2015-12-01 16:52:18 +00:00
|
|
|
# check if we rerun cell or not
|
2016-03-08 18:26:58 +00:00
|
|
|
rerun_cell = (args.rerun is not None and
|
|
|
|
args.rerun == 'odm_texturing') or \
|
|
|
|
(args.rerun_all) or \
|
|
|
|
(args.rerun_from is not None and
|
|
|
|
'odm_texturing' in args.rerun_from)
|
2015-12-01 16:52:18 +00:00
|
|
|
|
2015-12-10 11:01:41 +00:00
|
|
|
if not io.file_exists(tree.odm_textured_model_obj) or rerun_cell:
|
2016-02-26 18:50:12 +00:00
|
|
|
log.ODM_DEBUG('Writing ODM Textured file in: %s'
|
|
|
|
% tree.odm_textured_model_obj)
|
2015-12-02 12:20:21 +00:00
|
|
|
|
|
|
|
# odm_texturing definitions
|
|
|
|
kwargs = {
|
|
|
|
'bin': context.odm_modules_path,
|
2015-12-10 11:01:41 +00:00
|
|
|
'out_dir': tree.odm_texturing,
|
|
|
|
'bundle': tree.opensfm_bundle,
|
|
|
|
'imgs_path': tree.dataset_resize,
|
|
|
|
'imgs_list': tree.opensfm_bundle_list,
|
|
|
|
'model': tree.odm_mesh,
|
|
|
|
'log': tree.odm_texuring_log,
|
|
|
|
'resize': self.params.resize,
|
|
|
|
'resolution': self.params.resolution,
|
|
|
|
'size': self.params.size
|
2015-12-02 12:20:21 +00:00
|
|
|
}
|
|
|
|
|
2015-11-30 15:54:55 +00:00
|
|
|
# run texturing binary
|
2016-02-26 18:50:12 +00:00
|
|
|
system.run('{bin}/odm_texturing -bundleFile {bundle} '
|
|
|
|
'-imagesPath {imgs_path} -imagesListPath {imgs_list} '
|
|
|
|
'-inputModelPath {model} -outputFolder {out_dir}/ '
|
|
|
|
'-textureResolution {resolution} -bundleResizedTo {resize} '
|
|
|
|
'-textureWithSize {size} -logFile {log}'.format(**kwargs))
|
2015-11-30 15:54:55 +00:00
|
|
|
else:
|
2016-02-26 18:50:12 +00:00
|
|
|
log.ODM_WARNING('Found a valid ODM Texture file in: %s'
|
|
|
|
% tree.odm_textured_model_obj)
|
|
|
|
|
2016-03-08 18:26:58 +00:00
|
|
|
if args.time:
|
2016-02-29 14:45:00 +00:00
|
|
|
system.benchmark(start_time, tree.benchmarking, 'Texturing')
|
|
|
|
|
2016-03-08 18:26:58 +00:00
|
|
|
log.ODM_INFO('Running ODM Texturing Cell - Finished')
|
|
|
|
return ecto.OK if args.end_with != 'odm_texturing' else ecto.QUIT
|