When parsing the input JSON file, there might be some instances where
the `poses` key, unlike the `views` and `intrinsics` keys, does not exist.
If that is the case, an unhandled exception is raised while connections
are being made, which then causes issues for the lifetime of the Meshroom
instance.
This commit checks that the key exists before trying to access it, which
prevents raising unhandled exceptions while the active project is being
set up.
As the temporary CameraInit nodes are not really part of the graph, their
attributes cannot be edited. By default, the intrinsics can be edited for
any CameraInit node from the intrinsics table.
For temporary CameraInit nodes, we want the intrinsics to be displayed in
read-only mode to ensure that the user cannot attempt to edit them, which
would cause errors.
Upon its creation, the temporary CameraInit node is locked (as if it were
computed), and the intrinsics table's component are updated to be displayed
as read-only if the CameraInit node is locked.
If a LdrToHdrMerge node does not belong to the active group but is set as
active (by loading it with a double-click), if it is connected to another
CameraInit node, and if the "Visualize HDR images" has been enabled, then
the active group should be updated to that other CameraInit node.
By updating the active CameraInit's index, not only will the Image Gallery
display the newly selected LdrToHdrMerge thumbnails (already working prior
to this commit), but the Viewer2D will also be updated to reflect the
Gallery's selected thumbnail correctly. Information provided by the Gallery
will also reflect its content, as the active group will correspond to the
shown images, which was not the case before.
"Load Template" allows to load an .mg file as a regular project file,
without taking into account if it is a template.
If the project file is not a template, it will be opened exactly as if the
"Open File" menu had been used. If it is a template and it contains
"Publish" nodes, they will not be filtered out (whereas they will be if
the template is opened with "Open File" or through the "New" actions).
This commit adds an option to the "load" method, "publishOutputs", that
determines whether "Publish" nodes in a template project file should be
ignored during the graph's creation.
If "publishOutputs=True", then the "Publish" nodes from the template will
be added to the graph. "Publish" nodes in a project file that is not
a template will not be affected by this and will always be added to the
graph, as any other node.
This allows to have templates that are compatible with meshroom_batch,
which requires a "Publish" node when the --output option is specified,
while not having unneeded nodes in the UI or unneeded operations:
when --output is specified in meshroom_batch, "publishOutputs=True",
otherwise it will be set to False so that the "Publish" nodes are not
executed needlessly.
The metadata value of the viewpoint is meant to be a string, but if the
viewpoint attribute has already been removed and does not exist anymore,
then the metadata value becomes a PySide property.
When trying to access that property, an exception is raised. This commit
avoids raising exceptions in that case by checking that the viewpoint
attribute still exists (the metadata value is a string instance) before
accessing the metadata value.
This fixes the "Failed to parse Viewpoint metadata: 'the JSON object must
be str, bytes or bytearray, not Property'" warning raised by the exception
which occurred every single time there was a switch between cameraInit
groups that had been cleared.
When importing images, the intrinsics were (re)built asynchronously in
a thread that was not attached to anything. The update of the intrinsics,
performed in the main thread following a signal emitted in the detached
thread, would block when there were already some existing intrinsics
because the garbage collector would destroy the thread in which the
new intrinsics had been computed while the update was ongoing.
This commit adds a ThreadPool to the Reconstruction object, and uses it
to perform the intrinsics computations asynchronously. The update of the
intrinsics thus does not remain blocked and images can be imported safely,
either though the "Import Images" menu or through drag & drop.
The "Update Intrinsics" button, which appears when the dialog to edit the
sensor database is on display, also uses the ThreadPool to recompute the
intrinsics when requested.
The "runAsync" method, which spawned a thread without attaching it to
anything, is removed. The "importImagesAsync" method, whose only goal
was to call "runAsync" on "importImagesSync", is also removed. Instead,
the pool of threads is directly used to call "importImagesSync"
asynchronously.
Loading images with the "Import Images" menu action is a blocking
operation that might freeze the app if there are many images to import.
This commit performs the import asynchronously (similarly to what is done
when images are dropped in the Image Gallery): Meshroom remains unusable
while the images are imported and the intrinsics built (which is a wanted
behaviour), but it does not freeze at all.
In particular:
- In common/, remove the backport of weakref.WeakMethod
- In docs/ and ui/, use the standard FileNotFoundError class
- Use built-in open() instead of io.open(), and stop importing io
- In core/stats.py, use the standard implementation of xml.etree instead
of the C one
- "pyCompatibility.basestring" are replaced by standard Python3 "str"
- "Sequence" and "Iterable" from "collections" are now directly imported
with "collections.abc"
If a node of type "CameraInit" is double-clicked in the Graph Editor,
the Image Gallery group index will immediately be updated to display
the corresponding node's information.
- Support loading external pipelines as templates with project files
- Add template files for some standard pipelines
- Remove the hard-coded generation of new pipelines
- Update multiviewPipeline test: the multiviewPipeline test relied on the hard-coded generation of
pipelines.
PySide 5.15.1 and newer have a bug
(https://bugreports.qt.io/browse/PYSIDE-1426) which results in the
following error emitted on certain @Property decorators:
TypeError: A constant property cannot have a WRITE method or a NOTIFY
signal.
Until the bug is fixed on PySide2 side workaround is to not use Property
as a decorator, but as a simple function wrapper emitting the property
as a class member.
Fixes#1239.