mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-10 15:46:54 +02:00
[ui] simplify meshroom command line rules
This commit is contained in:
parent
a53940d29f
commit
ce6dcbae4d
1 changed files with 3 additions and 20 deletions
|
@ -59,15 +59,13 @@ class MeshroomApp(QApplication):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog=args[0], description='Launch Meshroom UI.', add_help=True)
|
parser = argparse.ArgumentParser(prog=args[0], description='Launch Meshroom UI.', add_help=True)
|
||||||
|
|
||||||
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
|
parser.add_argument('project', metavar='PROJECT', type=str, nargs='?',
|
||||||
help='Meshroom project file (e.g. myProject.mg) or folder with images to reconstruct.')
|
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='*',
|
parser.add_argument('-i', '--import', metavar='IMAGES/FOLDERS', type=str, nargs='*',
|
||||||
help='Import images or folder with images to reconstruct.')
|
help='Import images or folder with images to reconstruct.')
|
||||||
parser.add_argument('-I', '--importRecursive', metavar='FOLDERS', type=str, nargs='*',
|
parser.add_argument('-I', '--importRecursive', metavar='FOLDERS', type=str, nargs='*',
|
||||||
help='Import images to reconstruct from specified folder and sub-folders.')
|
help='Import images to reconstruct from specified folder and sub-folders.')
|
||||||
parser.add_argument('-p', '--project', metavar='MESHROOM_FILE', type=str, required=False,
|
parser.add_argument('-p', '--pipeline', metavar='MESHROOM_FILE', type=str, required=False,
|
||||||
help='Meshroom project file (e.g. myProject.mg).')
|
|
||||||
parser.add_argument('-P', '--pipeline', metavar='MESHROOM_FILE', type=str, required=False,
|
|
||||||
help='Override the default Meshroom pipeline with this external graph.')
|
help='Override the default Meshroom pipeline with this external graph.')
|
||||||
|
|
||||||
args = parser.parse_args(args[1:])
|
args = parser.parse_args(args[1:])
|
||||||
|
@ -130,29 +128,14 @@ class MeshroomApp(QApplication):
|
||||||
if defaultPipeline:
|
if defaultPipeline:
|
||||||
r.setDefaultPipeline(args.pipeline)
|
r.setDefaultPipeline(args.pipeline)
|
||||||
|
|
||||||
if args.input:
|
|
||||||
if not os.path.isfile(args.input) and not os.path.isdir(args.input):
|
|
||||||
raise RuntimeError(
|
|
||||||
"Meshroom Command Line Error: 'INPUT' argument should be a Meshroom project file (.mg) or a folder with input images.\n"
|
|
||||||
"Invalid value: '{}'".format(args.input))
|
|
||||||
if args.project and not os.path.isfile(args.project):
|
if args.project and not os.path.isfile(args.project):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Meshroom Command Line Error: '--project' argument should be a Meshroom project file (.mg).\n"
|
"Meshroom Command Line Error: 'PROJECT' argument should be a Meshroom project file (.mg).\n"
|
||||||
"Invalid value: '{}'".format(args.project))
|
"Invalid value: '{}'".format(args.project))
|
||||||
|
|
||||||
if args.project and args.input and not os.path.isdir(args.input):
|
|
||||||
raise RuntimeError("Meshroom Command Line Error: 'INPUT' and '--project' arguments cannot both load a Meshroom project file (.mg).")
|
|
||||||
|
|
||||||
if args.project:
|
if args.project:
|
||||||
r.load(args.project)
|
r.load(args.project)
|
||||||
|
|
||||||
if args.input:
|
|
||||||
if os.path.isfile(args.input):
|
|
||||||
# we assume that it is an ".mg" file.
|
|
||||||
r.load(args.input)
|
|
||||||
elif os.path.isdir(args.input):
|
|
||||||
r.importImagesFromFolder(args.input, recursive=False)
|
|
||||||
|
|
||||||
# import is a python keyword, so we have to access the attribute by a string
|
# import is a python keyword, so we have to access the attribute by a string
|
||||||
if getattr(args, "import", None):
|
if getattr(args, "import", None):
|
||||||
r.importImagesFromFolder(getattr(args, "import"), recursive=False)
|
r.importImagesFromFolder(getattr(args, "import"), recursive=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue