Repository navigation
[meshroom] Add IntrinsicsEditing node to edit the values of one intrinsic - #2272
Open
servantftransperfect wants to merge 10 commits into
Open
servantftransperfect wants to merge 10 commits into
servantftransperfect wants to merge 10 commits into
Conversation
servantftransperfect
requested review from
CedricThebault,
cbentejac and
fabiencastan
November 24, 2026 10:58
servantftransperfect
force-pushed
the
dev/intrinsicsEdit
branch
3 times, most recently
from
November 26, 2026 12:31
6701ea0 to
1da153a
Compare
An uncaught C++ exception thrown by a wrapped function (e.g. when loading an invalid SfMData file) terminated the Python process. It is now raised as a Python exception: ValueError for invalid_argument and domain_error, IndexError for out_of_range, OverflowError, MemoryError for bad_alloc, and RuntimeError for the other ones.
…ons and undistortions Declare the whole intrinsic hierarchy in IntrinsicBase.i, and the distortion and undistortion ones in Distortion.i and Undistortion.i, before any class or factory function (createIntrinsic, createDistortion, ...) is parsed, so the returned shared_ptr are usable from Python. EInitMode is included before IntrinsicBase so that SWIG matches the overrides of its pure virtual methods and does not consider the derived classes abstract.
…icBase.i getInitializationMode() returned an opaque pointer in modules such as sfmData, which include IntrinsicBase.i but not IntrinsicInitMode.i. The EInitMode stream operators are ignored: they are not usable from Python and their __lshift__ clashes with other headers' in those modules.
CachedSfmData keeps the last SfMData it loaded and returns it again as long as the path, the sfmDataIO loading flags, and the file inode, modification and change times and size are unchanged. It is meant for interactive code, such as Meshroom node callbacks, that reads the same SfMData repeatedly. A missing file returns None and clears the cache. A file that cannot be loaded returns None and is cached as such: it is not reloaded (nor logged) again until it changes.
Logic of the IntrinsicsEditing Meshroom node, kept outside the node descriptor so that it can be used and tested without Meshroom. - The intrinsic is selected by its ID as a string, or "auto" for the only intrinsic of the SfMData. - A field is an edit if and only if it differs from the value it was filled with (its snapshot), so unchanged fields keep the input's value. - Edits still at their default value (e.g. a focal length of 0), non-finite values and non-positive focal, ratio, sensor or radius values are rejected. - The camera type is checked, never modified. Distortion and undistortion are left untouched. - The sensor width is applied before the focal length (in mm). An unknown input focal length (<= 0, or a scale with a zero component) stays unknown unless the focal length is edited. - The initial focal length (the focal prior of bundle adjustment) is set to the focal length whenever the focal length in pixels is recomputed, or to -1 (no prior) if the prior is disabled. - Each applied edit is logged as "name: old -> new", with the resulting scale and initial scale in pixels.
…nsic Pure Python node (Utils) editing the focal length (mm), pixel ratio, principal point offset from the image center, sensor size, fisheye circle (equidistant only) and lock states of one intrinsic of an SfMData. - The fields are filled from the input intrinsic, and the filled values are saved in a hidden snapshot group: only the fields that differ from their snapshot are applied at compute. - Changing the intrinsic ID refills all the fields and discards the edits. Changing the input, or the "Refresh From Input" button, refills only the fields left unchanged; the button also sets the camera type to the input's. - The intrinsic ID list is saved with the project and rebuilt when the input changes or is refreshed. A selected ID missing from the new input is reset to "auto". The input is read through CachedSfmData with the INTRINSICS flag only. - Attribute writes from callbacks are grouped in a single graph update, and callback errors are logged instead of interrupting Meshroom's attribute change handling. - "Use Focal Length Prior" sets the initial focal length from the edited focal length, or disables the prior. - Locks are "keep", "locked" or "unlocked". - The verbose level applies to both the Python and the AliceVision loggers.
servantftransperfect
force-pushed
the
dev/intrinsicsEdit
branch
from
November 26, 2026 15:48
1da153a to
56c6d4b
Compare
…D is not in the input On node creation (e.g. from a pipeline template), a preset intrinsic ID missing from a readable input was reset to "auto". The reset triggered the intrinsic ID callback, which refilled all the fields and reset the locks to "keep", discarding the preset values with only a warning about the ID. - On node creation, a missing ID is kept in the ID list and stays selected: the computation fails on it instead of editing another intrinsic. - When the input changes or is refreshed, a missing ID is still reset to "auto"; the warning now says the fields and locks are refilled.
…id scale checkEdits only checks the edited fields, and the focal length in mm is converted to pixels with the input's sensor width. Editing only the focal length of an intrinsic with a sensor width <= 0 wrote an infinite or negative scale (an infinite one also made the initial scale infinite, and the output could not be loaded again). - Recomputing the focal length in pixels now requires a sensor width > 0, either from the input or edited. - A recomputed scale that is not finite and > 0 (e.g. an image size of 0) is rejected. The initial scale is then always set from a valid scale. - Add pyTests for intrinsicsEditing.
…idth is unknown A pixel ratio edit was applied only if the input focal length in mm was > 0. With a valid scale in pixels but a sensor width of 0 (e.g. from an Alembic or USD input), the focal length in mm is 0: the edit was only logged as "not applied" and the computation succeeded. - When the focal length is known in pixels only, the pixel ratio is applied to the scale with the convention of setFocalLength (fy kept, fx = fy / pixel ratio). - When the input scale is unknown, a pixel ratio edit is rejected instead of being dropped.
…er maps The SharedPtrMap wrappers (Views, Poses, ImageInfos) threw std::out_of_range for a missing key in __getitem__ and __delitem__, which exception.i converts into IndexError, where Python code expects KeyError as for a dict. - Add aliceVision_MissingKeyError (derived from std::out_of_range) to exception.i, raised as KeyError(key). - Throw it from the SharedPtrMap __getitem__ and __delitem__. The std::map wrappers generated by SWIG (e.g. Intrinsics, Rigs) are not changed: SWIG's std_map.i already raises IndexError for them.
|
|
||
| for mapping in (data.getViews(), data.getPoses(), data.getIntrinsics()): | ||
| with pytest.raises(KeyError) as error: | ||
| mapping[missing_id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
New
IntrinsicsEditingnode (Utils) to edit by hand the values of one camera intrinsic of an SfMData: focal length, pixel ratio, principal point, sensor size, fisheye circle and lock states.Distortion and undistortion are not modified, and the camera type cannot be changed.
Features list
[python]C++ exceptions thrown by wrapped functions (e.g. when loading an invalid SfMData) are raised as Python exceptions instead of terminating the process.[camera]SWIG: declare theshared_ptrtypes of the intrinsic, distortion and undistortion hierarchies, so that the objects returned bycreateIntrinsic,createDistortion, ... are usable from Python.[python]CachedSfmData: keeps the last loaded SfMData and reloads it only when the file changes (path, loading flags, modification time and size).[python]intrinsicsEditing: the node's logic, usable and testable without Meshroom.[meshroom]IntrinsicsEditingnode:autostands for the only intrinsic of the input, and is an error if there are several.keepthe input's state, or forcelocked/unlocked.Implementation remarks
snapshotgroup. At compute, a field is applied only if it differs from its snapshot, so untouched fields keep the input's value even if the input changed since. Each applied edit is logged asname: old -> new.advanced(hidden from the Node Editor by default) rather than disabled, because disabled attributes are left out of the node UID. Meshroom has no per-attribute read-only flag, so it stays editable when advanced attributes are shown.CachedSfmDatawith theINTRINSICSflag only, and the attribute writes of a callback are grouped in a single graph update.