Expose more SMVS parameters

pull/889/head
Dakota Benjamin 2018-06-30 19:36:53 -04:00
rodzic 2433323c6d
commit 3e962dceb6
4 zmienionych plików z 76 dodań i 14 usunięć

Wyświetl plik

@ -140,12 +140,13 @@ def config():
default=False,
help='Turn off camera parameter optimization during bundler')
parser.add_argument('--opensfm-processes',
parser.add_argument('--max-concurrency',
metavar='<positive integer>',
default=context.num_cores,
type=int,
help=('The maximum number of processes to use in dense '
'reconstruction. Default: %(default)s'))
help=('The maximum number of processes to use in various '
'processes. Peak memory requirement is ~1GB per '
'thread and 2 megapixel image resolution. Default: %(default)s'))
parser.add_argument('--opensfm-depthmap-resolution',
metavar='<positive float>',
@ -197,6 +198,13 @@ def config():
default=False,
help='Use opensfm to compute dense point cloud alternatively')
parser.add_argument('--smvs-alpha',
metavar='<float>',
default=1.0,
type=float,
help='Regularization parameter, a higher alpha leads to '
'smoother surfaces. Default: %(default)s')
parser.add_argument('--smvs-scale',
metavar='<non-negative integer>',
default=1,
@ -205,6 +213,34 @@ def config():
' density. 0 is original scale but takes longer '
'to process. 2 is 1/4 scale. Default: %(default)s')
parser.add_argument('--smvs-output-scale',
metavar='<positive integer>',
default=2,
type=int,
help='The scale of the optimization - the '
'finest resolution of the bicubic patches will have the'
' size of the respective power of 2 (e.g. 2 will '
'optimize patches covering down to 4x4 pixels). '
'Default: %(default)s')
parser.add_argument('--smvs-enable-shading',
action='store_true',
default=False,
help='Use shading-based optimization. This model cannot '
'handle complex scenes. Try to supply linear images to '
'the reconstruction pipeline that are not tone mapped '
'or altered as this can also have very negative effects '
'on the reconstruction. If you have simple JPGs with SRGB '
'gamma correction you can remove it with the --smvs-gamma-srgb '
'option. Default: %(default)s')
parser.add_argument('--smvs-gamma-srgb',
action='store_true',
default=False,
help='Apply inverse SRGB gamma correction. To be used '
'with --smvs-enable-shading when you have simple JPGs with '
'SRGB gamma correction. Default: %(default)s')
parser.add_argument('--cmvs-maxImages',
metavar='<integer>',
default=500,

Wyświetl plik

@ -44,8 +44,13 @@ def copy(src, dst):
def rename_file(src, dst):
try:
os.rename(src, dst)
return True
except OSError as e:
raise
if e.errno == errno.ENOENT:
return False
else:
raise
# find a file in the root directory
def find(filename, folder):

Wyświetl plik

@ -45,7 +45,7 @@ class ODMApp(ecto.BlackBox):
'opensfm': ODMOpenSfMCell(use_exif_size=False,
feature_process_size=p.args.resize_to,
feature_min_frames=p.args.min_num_features,
processes=p.args.opensfm_processes,
processes=p.args.max_concurrency,
matching_gps_neighbors=p.args.matcher_neighbors,
matching_gps_distance=p.args.matcher_distance,
fixed_camera_params=p.args.use_fixed_camera_params,
@ -58,7 +58,13 @@ class ODMApp(ecto.BlackBox):
wsize=p.args.pmvs_wsize,
min_imgs=p.args.pmvs_min_images,
cores=p.args.pmvs_num_cores),
'smvs': ODMSmvsCell(scale=p.args.smvs_scale), #TODO: add more options
'smvs': ODMSmvsCell(alpha=p.args.smvs_alpha,
scale=p.args.smvs_scale,
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),
'meshing': ODMeshingCell(max_vertex=p.args.mesh_size,
oct_tree=p.args.mesh_octree_depth,
samples=p.args.mesh_samples,

Wyświetl plik

@ -8,7 +8,13 @@ from opendm import context
class ODMSmvsCell(ecto.Cell):
def declare_params(self, params):
params.declare("threads", "max number of threads", context.num_cores)
params.declare("alpha", "Regularization parameter", 1)
params.declare("scale", "input scale", 1)
params.declare("output_scale", "scale of optimization", 2)
params.declare("shading", "Enable shading-aware model", False)
params.declare("gamma_srgb", "Apply inverse SRGB gamma correction", False)
params.declare("verbose", "Increase debug level", False)
def declare_io(self, params, inputs, outputs):
inputs.declare("tree", "Struct with paths", [])
@ -33,9 +39,6 @@ class ODMSmvsCell(ecto.Cell):
log.ODM_ERROR('Not enough photos in photos array to start SMVS')
return ecto.QUIT
# create working directories
system.mkdir_p(tree.smvs)
# check if we rerun cell or not
rerun_cell = (args.rerun is not None and
args.rerun == 'smvs') or \
@ -45,6 +48,7 @@ class ODMSmvsCell(ecto.Cell):
# check if reconstruction was done before
if not io.file_exists(tree.smvs_model) or rerun_cell:
# make bundle directory
if not io.file_exists(tree.mve_bundle):
system.mkdir_p(tree.mve_path) #TODO: check permissions/what happens when rerun
@ -52,18 +56,29 @@ class ODMSmvsCell(ecto.Cell):
io.copy(tree.opensfm_image_list, tree.mve_image_list)
io.copy(tree.opensfm_bundle, tree.mve_bundle)
# run mve makescene
if not io.dir_exists(tree.mve_path):
system.run('%s %s %s' % (context.makescene_path, tree.mve_path, tree.smvs))
# config
config = [
"-s%s" % self.params.scale
"-t%s" % self.params.threads,
"-a%s" % self.params.alpha,
"-s%s" % self.params.scale,
"-o%s" % self.params.output_scale,
"--debug-lvl=%s" % '1' if self.params.verbose else '0',
"%s" % '-S' if self.params.shading else '',
"%s" % '-g' if self.params.gamma_srgb and self.params.shading else '',
"--force" if rerun_cell else ''
]
# run mve makescene
system.run('%s %s %s' % (context.makescene_path, tree.mve_path, tree.smvs))
# run smvs
system.run('%s %s %s' % (context.smvs_path, ' '.join(config), tree.smvs))
# rename the file for simplicity
io.rename_file(io.join_paths(tree.smvs, 'smvs-B%s.ply' % self.params.scale), tree.smvs_model)
old_file = io.join_paths(tree.smvs, 'smvs-%s%s.ply' %
('S' if self.params.shading else 'B', self.params.scale))
if not (io.rename_file(old_file, tree.smvs_model)):
log.ODM_WARNING("File %s does not exist, cannot be renamed. " % old_file)
else: