mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
Merge pull request #2518 from alicevision/dev/cmdlineHelp
[ui] Improve command line help message
This commit is contained in:
commit
00c3ffd4c1
2 changed files with 223 additions and 66 deletions
|
@ -16,63 +16,119 @@ import logging
|
||||||
|
|
||||||
meshroom.core.initPipelines()
|
meshroom.core.initPipelines()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Launch the full photogrammetry or Panorama HDR pipeline.')
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument('-i', '--input', metavar='NODEINSTANCE:"SFM/FOLDERS/IMAGES;..."', type=str, nargs='*',
|
prog='meshroom_batch',
|
||||||
default=[],
|
description='Launch a Meshroom pipeline from command line.',
|
||||||
help='Input folder containing images or folders of images or file (.sfm or .json) '
|
add_help=True,
|
||||||
'with images paths and optionally predefined camera intrinsics.')
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
parser.add_argument('-I', '--inputRecursive', metavar='NODEINSTANCE:"FOLDERS/IMAGES;..."', type=str, nargs='*',
|
epilog='''
|
||||||
default=[],
|
Examples:
|
||||||
help='Input folders containing all images recursively.')
|
1. Process a pipeline in command line:
|
||||||
|
meshroom_batch -p cameraTracking -i /input/path -o /output/path -s /path/to/store/the/project.mg
|
||||||
|
|
||||||
parser.add_argument('-p', '--pipeline', metavar='FILE.mg/' + '/'.join(meshroom.core.pipelineTemplates), type=str, default='photogrammetry',
|
2. Submit a pipeline on renderfarm:
|
||||||
help='Template pipeline among those listed or a Meshroom file containing a custom pipeline to run on input images. '
|
meshroom_batch -p cameraTracking -i /input/path -o /output/path -s /path/to/store/the/project.mg --submit
|
||||||
'Requirements: the graph must contain one CameraInit node, '
|
|
||||||
'and one Publish node if --output is set.')
|
|
||||||
|
|
||||||
parser.add_argument('--overrides', metavar='SETTINGS', type=str, default=None,
|
See "meshroom_compute -h" to compute an existing project from command line.
|
||||||
help='A JSON file containing the graph parameters override.')
|
|
||||||
|
|
||||||
parser.add_argument('--paramOverrides', metavar='NODETYPE:param=value NODEINSTANCE.param=value', type=str, default=None, nargs='*',
|
Additional Resources:
|
||||||
help='Override specific parameters directly from the command line (by node type or by node names).')
|
Website: https://alicevision.org
|
||||||
|
Manual: https://meshroom-manual.readthedocs.io
|
||||||
|
Forum: https://groups.google.com/g/alicevision
|
||||||
|
Tutorials: https://www.youtube.com/c/AliceVisionOrg
|
||||||
|
Contribute: https://github.com/alicevision/Meshroom
|
||||||
|
''')
|
||||||
|
|
||||||
parser.add_argument('-o', '--output', metavar='FOLDER', type=str, required=False,
|
|
||||||
help='Output folder where results should be copied to. '
|
|
||||||
'If not set, results will have to be retrieved directly from the cache folder.')
|
|
||||||
|
|
||||||
parser.add_argument('--cache', metavar='FOLDER', type=str,
|
general_group = parser.add_argument_group('General Options')
|
||||||
default=None,
|
general_group.add_argument(
|
||||||
help='Custom cache folder to write computation results. '
|
'-i', '--input', metavar='NODEINSTANCE:"SFM/FOLDERS/IMAGES;..."', type=str, nargs='*',
|
||||||
'If not set, the default cache folder will be used: ' + meshroom.core.defaultCacheFolder)
|
default=[],
|
||||||
|
help='Input folder containing images or folders of images or file (.sfm or .json) '
|
||||||
|
'with images paths and optionally predefined camera intrinsics.')
|
||||||
|
|
||||||
parser.add_argument('--save', metavar='FILE', type=str, required=False,
|
general_group.add_argument(
|
||||||
help='Save the configured Meshroom graph to a project file. It will setup the cache folder accordingly if not explicitly changed by --cache.')
|
'-I', '--inputRecursive', metavar='NODEINSTANCE:"FOLDERS/IMAGES;..."', type=str, nargs='*',
|
||||||
|
default=[],
|
||||||
|
help='Input folders containing all images recursively.')
|
||||||
|
|
||||||
parser.add_argument('--compute', metavar='<yes/no>', type=lambda x: bool(distutils.util.strtobool(x)), default=True, required=False,
|
general_group.add_argument(
|
||||||
help='You can set it to <no/false/0> to disable the computation.')
|
'-p', '--pipeline',
|
||||||
|
metavar='FILE.mg / PIPELINE',
|
||||||
|
type=str,
|
||||||
|
default=os.environ.get('MESHROOM_DEFAULT_PIPELINE', 'photogrammetry'),
|
||||||
|
help='Template pipeline among those listed or a Meshroom file containing a custom pipeline to run on input images:\n'
|
||||||
|
+ '\n'.join([' - ' + p for p in meshroom.core.pipelineTemplates])
|
||||||
|
+ '\nRequirements: the graph must contain one CameraInit node, and one Publish node if --output is set.',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument('--toNode', metavar='NODE', type=str, nargs='*',
|
general_group.add_argument(
|
||||||
default=None,
|
'-o', '--output', metavar='FOLDER', type=str, required=False,
|
||||||
help='Process the node(s) with its dependencies.')
|
help='Output folder where results should be copied to. '
|
||||||
|
'If not set, results will have to be retrieved directly from the cache folder.')
|
||||||
|
|
||||||
parser.add_argument('--forceStatus', help='Force computation if status is RUNNING or SUBMITTED.',
|
general_group.add_argument(
|
||||||
action='store_true')
|
'-s', '--save', metavar='FILE', type=str, required=False,
|
||||||
parser.add_argument('--forceCompute', help='Compute in all cases even if already computed.',
|
help='Save the configured Meshroom graph to a project file. It will setup the cache folder accordingly if not explicitly changed by --cache.')
|
||||||
action='store_true')
|
|
||||||
|
|
||||||
parser.add_argument('--submit', help='Submit on renderfarm instead of local computation.',
|
general_group.add_argument(
|
||||||
action='store_true')
|
'--submit', help='Submit on renderfarm instead of local computation.',
|
||||||
parser.add_argument("--submitLabel",
|
action='store_true')
|
||||||
type=str,
|
|
||||||
default='[Meshroom] {projectName}',
|
|
||||||
help="Label of a node in the submitter")
|
|
||||||
parser.add_argument('--submitter',
|
|
||||||
type=str,
|
|
||||||
default='SimpleFarm',
|
|
||||||
help='Execute job with a specific submitter.')
|
|
||||||
|
|
||||||
parser.add_argument('-v', '--verbose', help="Verbosity level", default='',
|
general_group.add_argument(
|
||||||
choices=['', 'fatal', 'error', 'warning', 'info', 'debug', 'trace'],)
|
'-v', '--verbose',
|
||||||
|
help='Set the verbosity level for logging:\n'
|
||||||
|
' - fatal: Show only critical errors.\n'
|
||||||
|
' - error: Show errors only.\n'
|
||||||
|
' - warning: Show warnings and errors.\n'
|
||||||
|
' - info: Show standard informational messages.\n'
|
||||||
|
' - debug: Show detailed debug information.\n'
|
||||||
|
' - trace: Show all messages, including trace-level details.',
|
||||||
|
default=os.environ.get('MESHROOM_VERBOSE', 'warning'),
|
||||||
|
choices=['fatal', 'error', 'warning', 'info', 'debug', 'trace'])
|
||||||
|
|
||||||
|
advanced_group = parser.add_argument_group('Advanced Options')
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--overrides', metavar='SETTINGS', type=str, default=None,
|
||||||
|
help='A JSON file containing the graph parameters override.')
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--paramOverrides', metavar='NODETYPE:param=value NODEINSTANCE.param=value', type=str, default=None, nargs='*',
|
||||||
|
help='Override specific parameters directly from the command line (by node type or by node names).')
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--cache', metavar='FOLDER', type=str,
|
||||||
|
default=None,
|
||||||
|
help='Custom cache folder to write computation results. '
|
||||||
|
'If not set, the default cache folder will be used: ' + meshroom.core.defaultCacheFolder)
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--compute', metavar='<yes/no>', type=lambda x: bool(distutils.util.strtobool(x)), default=True, required=False,
|
||||||
|
help='You can set it to <no/false/0> to disable the computation.')
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--toNode', metavar='NODE', type=str, nargs='*',
|
||||||
|
default=None,
|
||||||
|
help='Process the node(s) with its dependencies.')
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--forceStatus', help='Force computation if status is RUNNING or SUBMITTED.',
|
||||||
|
action='store_true')
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--forceCompute', help='Compute in all cases even if already computed.',
|
||||||
|
action='store_true')
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
"--submitLabel",
|
||||||
|
type=str,
|
||||||
|
default=os.environ.get('MESHROOM_SUBMIT_LABEL', '[Meshroom] {projectName}'),
|
||||||
|
help="Label of a node when submitted on renderfarm.")
|
||||||
|
|
||||||
|
advanced_group.add_argument(
|
||||||
|
'--submitter',
|
||||||
|
type=str,
|
||||||
|
default='SimpleFarm',
|
||||||
|
help='Execute job with a specific submitter.')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -85,8 +141,7 @@ logStringToPython = {
|
||||||
'debug': logging.DEBUG,
|
'debug': logging.DEBUG,
|
||||||
'trace': logging.DEBUG,
|
'trace': logging.DEBUG,
|
||||||
}
|
}
|
||||||
if args.verbose:
|
logging.getLogger().setLevel(logStringToPython[args.verbose])
|
||||||
logging.getLogger().setLevel(logStringToPython[args.verbose])
|
|
||||||
|
|
||||||
if not args.input and not args.inputRecursive:
|
if not args.input and not args.inputRecursive:
|
||||||
print('Nothing to compute. You need to set --input or --inputRecursive.')
|
print('Nothing to compute. You need to set --input or --inputRecursive.')
|
||||||
|
|
|
@ -70,6 +70,118 @@ class MessageHandler(object):
|
||||||
return
|
return
|
||||||
MessageHandler.logFunctions[messageType](message)
|
MessageHandler.logFunctions[messageType](message)
|
||||||
|
|
||||||
|
def createMeshroomParser(args):
|
||||||
|
|
||||||
|
# Create the main parser with a description
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog='meshroom',
|
||||||
|
description='Launch Meshroom UI - The toolbox that connects research, industry and community at large.',
|
||||||
|
add_help=True,
|
||||||
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
|
epilog='''
|
||||||
|
Examples:
|
||||||
|
1. Open an existing project in Meshroom:
|
||||||
|
meshroom myProject.mg
|
||||||
|
|
||||||
|
2. Open a new project in Meshroom with a specific pipeline, import images from a folder and save the project:
|
||||||
|
meshroom -p photogrammetry -i /path/to/images/ --save /path/to/store/the/project.mg
|
||||||
|
|
||||||
|
3. Process a pipeline in command line:
|
||||||
|
meshroom_batch -p cameraTracking -i /input/path -o /output/path -s /path/to/store/the/project.mg
|
||||||
|
See 'meshroom_batch -h' for more details.
|
||||||
|
|
||||||
|
Additional Resources:
|
||||||
|
Website: https://alicevision.org
|
||||||
|
Manual: https://meshroom-manual.readthedocs.io
|
||||||
|
Forum: https://groups.google.com/g/alicevision
|
||||||
|
Tutorials: https://www.youtube.com/c/AliceVisionOrg
|
||||||
|
Contribute: https://github.com/alicevision/Meshroom
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
# Positional Arguments
|
||||||
|
parser.add_argument(
|
||||||
|
'project',
|
||||||
|
metavar='PROJECT',
|
||||||
|
type=str,
|
||||||
|
nargs='?',
|
||||||
|
help='Meshroom project file (e.g. myProject.mg) or folder with images to reconstruct.'
|
||||||
|
)
|
||||||
|
|
||||||
|
# General Options
|
||||||
|
general_group = parser.add_argument_group('General Options')
|
||||||
|
general_group.add_argument(
|
||||||
|
'-v', '--verbose',
|
||||||
|
help='Set the verbosity level for logging:\n'
|
||||||
|
' - fatal: Show only critical errors.\n'
|
||||||
|
' - error: Show errors only.\n'
|
||||||
|
' - warning: Show warnings and errors.\n'
|
||||||
|
' - info: Show standard informational messages.\n'
|
||||||
|
' - debug: Show detailed debug information.\n'
|
||||||
|
' - trace: Show all messages, including trace-level details.',
|
||||||
|
default=os.environ.get('MESHROOM_VERBOSE', 'warning'),
|
||||||
|
choices=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
|
||||||
|
)
|
||||||
|
general_group.add_argument(
|
||||||
|
'--submitLabel',
|
||||||
|
metavar='SUBMITLABEL',
|
||||||
|
type=str,
|
||||||
|
help='Label of a node when submitted on renderfarm.',
|
||||||
|
default=os.environ.get('MESHROOM_SUBMIT_LABEL', '[Meshroom] {projectName}'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Project and Input Options
|
||||||
|
project_group = parser.add_argument_group('Project and Input Options')
|
||||||
|
project_group.add_argument(
|
||||||
|
'-i', '--import',
|
||||||
|
metavar='IMAGES/FOLDERS',
|
||||||
|
type=str,
|
||||||
|
nargs='*',
|
||||||
|
help='Import images or a folder with images to process.'
|
||||||
|
)
|
||||||
|
project_group.add_argument(
|
||||||
|
'-I', '--importRecursive',
|
||||||
|
metavar='FOLDERS',
|
||||||
|
type=str,
|
||||||
|
nargs='*',
|
||||||
|
help='Import images to process from specified folder and sub-folders.'
|
||||||
|
)
|
||||||
|
project_group.add_argument(
|
||||||
|
'-s', '--save',
|
||||||
|
metavar='PROJECT.mg',
|
||||||
|
type=str,
|
||||||
|
required=False,
|
||||||
|
help='Save the created scene to the specified Meshroom project file.'
|
||||||
|
)
|
||||||
|
project_group.add_argument(
|
||||||
|
'-1', '--latest',
|
||||||
|
action='store_true',
|
||||||
|
help='Load the most recent scene (-2 and -3 to load the previous ones).'
|
||||||
|
)
|
||||||
|
project_group.add_argument(
|
||||||
|
'-2', '--latest2',
|
||||||
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS # This hides the option from the help message
|
||||||
|
)
|
||||||
|
project_group.add_argument(
|
||||||
|
'-3', '--latest3',
|
||||||
|
action='store_true',
|
||||||
|
help=argparse.SUPPRESS # This hides the option from the help message
|
||||||
|
)
|
||||||
|
|
||||||
|
# Pipeline Options
|
||||||
|
pipeline_group = parser.add_argument_group('Pipeline Options')
|
||||||
|
pipeline_group.add_argument(
|
||||||
|
'-p', '--pipeline',
|
||||||
|
metavar='FILE.mg / PIPELINE',
|
||||||
|
type=str,
|
||||||
|
default=os.environ.get('MESHROOM_DEFAULT_PIPELINE', ''),
|
||||||
|
help='Select the default Meshroom pipeline:\n'
|
||||||
|
+ '\n'.join([' - ' + p for p in meshroom.core.pipelineTemplates]),
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser.parse_args(args[1:])
|
||||||
|
|
||||||
|
|
||||||
class MeshroomApp(QApplication):
|
class MeshroomApp(QApplication):
|
||||||
""" Meshroom UI Application. """
|
""" Meshroom UI Application. """
|
||||||
|
@ -78,24 +190,7 @@ class MeshroomApp(QApplication):
|
||||||
|
|
||||||
QtArgs = [args[0], '-style', 'fusion'] + args[1:] # force Fusion style by default
|
QtArgs = [args[0], '-style', 'fusion'] + args[1:] # force Fusion style by default
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog=args[0], description='Launch Meshroom UI.', add_help=True)
|
args = createMeshroomParser(args)
|
||||||
|
|
||||||
parser.add_argument('project', metavar='PROJECT', type=str, nargs='?',
|
|
||||||
help='Meshroom project file (e.g. myProject.mg) or folder with images to reconstruct.')
|
|
||||||
parser.add_argument('-i', '--import', metavar='IMAGES/FOLDERS', type=str, nargs='*',
|
|
||||||
help='Import images or folder with images to reconstruct.')
|
|
||||||
parser.add_argument('-I', '--importRecursive', metavar='FOLDERS', type=str, nargs='*',
|
|
||||||
help='Import images to reconstruct from specified folder and sub-folders.')
|
|
||||||
parser.add_argument('-s', '--save', metavar='PROJECT.mg', type=str, default='',
|
|
||||||
help='Save the created scene.')
|
|
||||||
parser.add_argument('-p', '--pipeline', metavar="FILE.mg/" + "/".join(meshroom.core.pipelineTemplates), type=str,
|
|
||||||
default=os.environ.get("MESHROOM_DEFAULT_PIPELINE", ""),
|
|
||||||
help='Override the default Meshroom pipeline with this external or template graph.')
|
|
||||||
parser.add_argument("--submitLabel", metavar='SUBMITLABEL', type=str, help="Label of a node in the submitter", default='[Meshroom] {projectName}')
|
|
||||||
parser.add_argument("--verbose", help="Verbosity level", default=os.environ.get('MESHROOM_VERBOSE', 'warning'),
|
|
||||||
choices=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],)
|
|
||||||
|
|
||||||
args = parser.parse_args(args[1:])
|
|
||||||
|
|
||||||
logStringToPython = {
|
logStringToPython = {
|
||||||
'fatal': logging.FATAL,
|
'fatal': logging.FATAL,
|
||||||
|
@ -182,6 +277,13 @@ class MeshroomApp(QApplication):
|
||||||
args.project = os.path.abspath(args.project)
|
args.project = os.path.abspath(args.project)
|
||||||
self._activeProject.load(args.project)
|
self._activeProject.load(args.project)
|
||||||
self.addRecentProjectFile(args.project)
|
self.addRecentProjectFile(args.project)
|
||||||
|
elif args.latest or args.latest2 or args.latest3:
|
||||||
|
projects = self._recentProjectFiles()
|
||||||
|
if projects:
|
||||||
|
index = [args.latest, args.latest2, args.latest3].index(True)
|
||||||
|
project = os.path.abspath(projects[index]["path"])
|
||||||
|
self._activeProject.load(project)
|
||||||
|
self.addRecentProjectFile(project)
|
||||||
elif getattr(args, "import", None) or args.importRecursive or args.save or args.pipeline:
|
elif getattr(args, "import", None) or args.importRecursive or args.save or args.pipeline:
|
||||||
self._activeProject.new()
|
self._activeProject.new()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue