Skip to content

Commit

Permalink
Enable merge of multiple sfmDatas
Browse files Browse the repository at this point in the history
  • Loading branch information
servantftechnicolor committed Jan 21, 2025
1 parent 1f42ad3 commit 8d2f0f7
Showing 1 changed file with 23 additions and 41 deletions.
64 changes: 23 additions & 41 deletions meshroom/nodes/aliceVision/SfMMerge.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,31 @@
__version__ = "2.0"
__version__ = "3.0"

from meshroom.core import desc
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL

import os.path


class MergeNodeSize(object):
"""
MergeNodeSize expresses a dependency to two input attributess to define
the size of a Node in terms of individual tasks for parallelization.
"""
def __init__(self, param1, param2):
self._param1 = param1
self._param2 = param2

def computeSize(self, node):

size1 = 0
size2 = 0

param1 = node.attribute(self._param1)
if param1.isLink:
size1 = param1.getLinkParam().node.size

param2 = node.attribute(self._param2)
if param2.isLink:
size2 = param2.getLinkParam().node.size

return size1 + size2


class SfMMerge(desc.AVCommandLineNode):
commandLine = 'aliceVision_sfmMerge {allParams}'
size = MergeNodeSize('firstinput', 'secondinput')

category = 'Utils'
documentation = '''
Merges two SfMData files into a single one. Fails if some UID is shared among them.
'''

inputs = [
desc.File(
name="firstinput",
label="First SfMData",
description="First input SfMData file to merge.",
value="",
),
desc.File(
name="secondinput",
label="Second SfMData",
description="Second input SfMData file to merge.",
value="",
desc.ListAttribute(
elementDesc=desc.File(
name="input",
label="Input SfmData",
description="A SfmData file.",
value="",
),
name="inputs",
label="Inputs",
description="Set of SfmData (at least 1 is required).",
exposed=True,
),
desc.ChoiceParam(
name="method",
Expand Down Expand Up @@ -82,20 +56,28 @@ class SfMMerge(desc.AVCommandLineNode):
exclusive=False,
joinChar=",",
),
desc.ChoiceParam(
name="fileExt",
label="SfM File Format",
description="Output SfM file format.",
value="abc",
values=["abc", "sfm", "json"],
group="", # exclude from command line
),
desc.ChoiceParam(
name="verboseLevel",
label="Verbose Level",
description="Verbosity level (fatal, error, warning, info, debug, trace).",
values=VERBOSE_LEVEL,
value="info",
),
)
]

outputs = [
desc.File(
name="output",
label="SfMData",
description="Path to the output SfM file (in SfMData format).",
value=lambda attr: desc.Node.internalFolder + "sfmData.sfm",
),
value=lambda attr: desc.Node.internalFolder + "sfmData.{fileExtValue}",
)
]

0 comments on commit 8d2f0f7

Please sign in to comment.