Merge pull request #2654 from alicevision/dev/sfmMultiMerge

Enable merge of multiple sfmDatas
This commit is contained in:
Fabien Castan 2025-01-27 08:36:10 +01:00 committed by GitHub
commit 2bd98c34fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,39 +1,33 @@
__version__ = "2.0" __version__ = "3.0"
from meshroom.core import desc from meshroom.core import desc
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL
import os.path import os.path
class MergeNodeSize(desc.DynamicNodeSize):
class MergeNodeSize(object):
""" """
MergeNodeSize expresses a dependency to two input attributess to define MergeNodeSize expresses a dependency to multiple input attributess to define
the size of a Node in terms of individual tasks for parallelization. the size of a Node in terms of individual tasks for parallelization.
""" """
def __init__(self, param1, param2): def __init__(self, param):
self._param1 = param1 self._params = param
self._param2 = param2
def computeSize(self, node): def computeSize(self, node):
size1 = 0 size = 0
size2 = 0
param1 = node.attribute(self._param1) for input in node.attribute(self._params).value:
if param1.isLink: paramName = input.getFullName()
size1 = param1.getLinkParam().node.size param = node.attribute(paramName)
size = size + param.getLinkParam().node.size
param2 = node.attribute(self._param2) return size
if param2.isLink:
size2 = param2.getLinkParam().node.size
return size1 + size2
class SfMMerge(desc.AVCommandLineNode): class SfMMerge(desc.AVCommandLineNode):
commandLine = 'aliceVision_sfmMerge {allParams}' commandLine = 'aliceVision_sfmMerge {allParams}'
size = MergeNodeSize('firstinput', 'secondinput') size = MergeNodeSize("inputs")
category = 'Utils' category = 'Utils'
documentation = ''' documentation = '''
@ -41,17 +35,17 @@ Merges two SfMData files into a single one. Fails if some UID is shared among th
''' '''
inputs = [ inputs = [
desc.File( desc.ListAttribute(
name="firstinput", elementDesc=desc.File(
label="First SfMData", name="input",
description="First input SfMData file to merge.", label="Input SfmData",
description="A SfmData file.",
value="", value="",
), ),
desc.File( name="inputs",
name="secondinput", label="Inputs",
label="Second SfMData", description="Set of SfmData (at least 1 is required).",
description="Second input SfMData file to merge.", exposed=True,
value="",
), ),
desc.ChoiceParam( desc.ChoiceParam(
name="method", name="method",
@ -82,13 +76,21 @@ Merges two SfMData files into a single one. Fails if some UID is shared among th
exclusive=False, exclusive=False,
joinChar=",", 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( desc.ChoiceParam(
name="verboseLevel", name="verboseLevel",
label="Verbose Level", label="Verbose Level",
description="Verbosity level (fatal, error, warning, info, debug, trace).", description="Verbosity level (fatal, error, warning, info, debug, trace).",
values=VERBOSE_LEVEL, values=VERBOSE_LEVEL,
value="info", value="info",
), )
] ]
outputs = [ outputs = [
@ -96,6 +98,6 @@ Merges two SfMData files into a single one. Fails if some UID is shared among th
name="output", name="output",
label="SfMData", label="SfMData",
description="Path to the output SfM file (in SfMData format).", 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}",
), )
] ]