-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve command line arguments #632
Conversation
…save, add --compute - add short names for input/output - change --save option which allow to save the graph used but now do not replace the computation - new option to disable the computation (makes sense only if you want to only save the created project)
- "meshroom -h / --help": now provides command line documentation (so argparse is done before GUI creation) - new positional argument to set project file or input folder - new "--pipeline" option to set a default pipeline, also support an environment variable
…photogrammetry pipeline
… path except if --cache is set explicitly
meshroom/core/graph.py
Outdated
|
||
Args: | ||
filepath: project filepath to load | ||
fileLink: Setup link to the project file, like setup cacheDir, keep filepath for save, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileLink: Setup link to the project file, like setup cacheDir, keep filepath for save, etc. | |
fileLink: if false, it only loads the project file as a template (all the data is discarded) and only the bare structure of the graph is preserved. |
I found Setup link to the project file, like setup cacheDir, keep filepath for save, etc.
a bit obscure/confusing
meshroom/core/graph.py
Outdated
@@ -234,7 +234,15 @@ def fileFeatures(self): | |||
return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0")) | |||
|
|||
@Slot(str) | |||
def load(self, filepath): | |||
def load(self, filepath, fileLink=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileLink
is a bit obscure.
why not turn the table and use asTemplate=False
. I know that then all the conditions should be negate but it is less obscure than fileLink IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to avoid inverted negation: asTemplate=False
will do more actions (setup the cacheDir, etc.) and asTemplate=True
to do nothing.
I pushed a proposition for another name that doesn't negate the option: setupFileRef
.
Does that sound fine to you?
meshroom/ui/app.py
Outdated
r.loadUrl(QUrl.fromLocalFile(args.project)) | ||
r.load(args.project) | ||
|
||
if args.input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't input
and project
be exclusive?
At least if project
and input
both contain a .mg. In this case, I think it would be better to throw an error to let the user know that there is something wrong. (unless it is able to load both projects?)
And if we give project
and input
with folders, does it add the images to the current project? Something in the same spirit of meshroom_photogrammetry https://github.com/alicevision/meshroom/pull/632/files#diff-4f70151d95f3b3a1c7ea377cbaef3f10R114
# initialize photogrammetry pipeline
if args.pipeline:
# custom pipeline
graph = meshroom.core.graph.loadGraph(args.pipeline)
cameraInit = getOnlyNodeOfType(graph, 'CameraInit')
# reset graph inputs
cameraInit.viewpoints.resetValue()
cameraInit.intrinsics.resetValue()
# add views and intrinsics (if any) read from args.input
cameraInit.viewpoints.extend(views)
cameraInit.intrinsics.extend(intrinsics)
if not graph.canComputeLeaves:
raise RuntimeError("Graph cannot be computed. Check for compatibility issues.")
if args.output:
publish = getOnlyNodeOfType(graph, 'Publish')
publish.output.value = args.output
else:
# default pipeline
graph = multiview.photogrammetry(inputViewpoints=views, inputIntrinsics=intrinsics, output=args.output)
cameraInit = getOnlyNodeOfType(graph, 'CameraInit')
if images:
views, intrinsics = cameraInit.nodeDesc.buildIntrinsics(cameraInit, images)
cameraInit.viewpoints.value = views
cameraInit.intrinsics.value = intrinsics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is no error for now but that's the usage intention.
So you're right, we can enforce the fact that it should be exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed and I have also added another argument "--import".
- explicit error messages - allow to combine multiple inputs with new --import and --importRecursive options
@@ -61,9 +61,13 @@ def __init__(self, args): | |||
|
|||
parser.add_argument('input', metavar='INPUT', type=str, nargs='?', | |||
help='Meshroom project file (e.g. myProject.mg) or folder with images to reconstruct.') | |||
parser.add_argument('--project', metavar='MESHROOM_FILE', type=str, required=False, | |||
parser.add_argument('-i', '--import', metavar='IMAGES/FOLDERS', type=str, nargs='*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't now the arguments a little bit too redundant?
We can get rid of input
at this point and just use project and the imports. It makes life easier, it's more readable and less confusing, and we don't need to check for conflicts. And too bad if we break compatibility, we already broke it with photogrammetry.
meshroom/core/graph.py
Outdated
@@ -234,14 +234,14 @@ def fileFeatures(self): | |||
return Graph.IO.getFeaturesForVersion(self.header.get(Graph.IO.Keys.FileVersion, "0.0")) | |||
|
|||
@Slot(str) | |||
def load(self, filepath, fileLink=True): | |||
def load(self, filepath, setupFileRef=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about overrideProjectFile
?
meshroom/core/graph.py
Outdated
|
||
Args: | ||
filepath: project filepath to load | ||
setupFileRef: Setup reference to the project file, like setup cacheDir, keep filepath for save, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setupFileRef: Setup reference to the project file, like setup cacheDir, keep filepath for save, etc. | |
overrideProjectFile: Override the input project file (any changes will be overwritten on the file) and use its cache directories. If false, it only loads the graph of the project file as a template. |
n.attribute(param).value = value | ||
elif t == '.': | ||
print('Overrides {node}.{param}={value}'.format(node=node, param=param, value=value)) | ||
graph.findNode(node).attribute(param).value = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just asking, findNode(node)
can fail in the same way as nodesByType(node)
? Shall we manage the error?
Also, very minor thing, I'd put the print after the setting is done so it is not print in case of failure (hopefully findNode(node)
or attribute(param)
will print or raise some kind of error?)
In case, the same for the previous nodesByType(node)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findNode is looking for one specific node and fails with an explicit message if it doesn't find it.
nodesByType looks for all nodes of a specific type and can return an empty list without error (that's why there is a specific check to provide an error message).
I put the print before so it's more visible in the error message :s, the last NODE.PARAM is printed and then you have the error message saying that it doesn't find PARAM for instance.
Description
This PR improves meshroom_photogrammetry and meshroom command lines.
Features list
Implementation