-
Notifications
You must be signed in to change notification settings - Fork 7
2 DevDoc
Here are the basics on how to implement new nodes:
- CommandLineNodes: nodes run external cli programs - this is how most Meshroom nodes work. Simple example
class Convert2MVE(desc.CommandLineNode):
commandLine = 'aliceVision_exportMVE2 {allParams}'
Runs aliceVision_exportMVE2.exe with all parameters. {allParams} is supported by native alicevision plugins (loads all parameters with --param).
For external programs cli parameters need to be adjusted (example):
class ImageMasking(desc.CommandLineNode):
commandLine = 'mogrify -format png -path {outputValue} -type Grayscale -negate -fill black -fuzz {fuzzValue}% +opaque "#ffffff" -blur {radiusValue}x{sigmaValue} -type Bilevel -depth 1 {inputValue}/*jpg'
Runs mogrify.exe with defined parameters
- Native Python nodes
It is possible to implement new nodes in python without running an external program from the cli.
Here is a good examples for pure python nodes: https://github.com/alicevision/meshroom/blob/develop/meshroom/nodes/aliceVision/SketchfabUpload.py and https://github.com/alicevision/meshroom/pull/641/files (import modules)
Additional packages can be copied into the 'lib' folder ('/meshroom-2019.2.0/lib')
Good reference: https://github.com/natowi/meshroom_external_plugins/issues/2
GUI elements
References on different supported GUI elements for nodes can be found here
Meshroom default nodes support the following GUI elements:
version = "1.1" --> needs to be increased to avoid incompatibility issues
File
desc.File(
name='outputTextures',
label='Output Textures',
description='Folder for output mesh: OBJ, material and texture files.',
value=desc.Node.internalFolder + 'texture_*.{outputTextureFileTypeValue}',
uid=[],
group='',
),
DropDown
desc.ChoiceParam(
name='textureSide',
label='Texture Side',
description='''Output texture size''',
value=8192,
values=(1024, 2048, 4096, 8192, 16384),
exclusive=True,
uid=[0],
),
String
`desc.StringParam(`
`name='depthMapExp',`
`label='Depth Mask Expression',`
`description='''Depth Mask Expression, like "{inputFolder}/{stem}-depth.{ext}".''',`
`value='',`
`uid=[0],`
`),`
Checkbox (Boolean)
desc.BoolParam(
name='fillHoles',
label='Fill Holes',
description='Fill Texture holes with plausible values',
value=False,
uid=[0],
),
RangeSlider (Integer)
advanced=True, --> hide option by default, show only in advanced mode
desc.IntParam(
name='padding',
label='Padding',
description='''Texture edge padding size in pixel''',
value=5,
range=(0, 20, 1),
uid=[0],
advanced=True,
),
RangeSlider (Float)
desc.FloatParam(
name='bestScoreThreshold',
label='Best Score Threshold',
description='''(0.0 to disable filtering based on threshold to relative best score)''',
value=0.1,
range=(0.0, 1.0, 0.01),
uid=[0],
advanced=True,
),
GroupAttribute
desc.GroupAttribute(
name="multiBandNbContrib",
label="MultiBand contributions",
groupDesc=[
desc.IntParam(name="high", label="High Freq", description="High Frequency Band", value=1, uid=[0], range=None),
desc.IntParam(name="midHigh", label="Mid-High Freq", description="Mid-High Frequency Band", value=5, uid=[0], range=None),
desc.IntParam(name="midLow", label="Mid-Low Freq", description="Mid-Low Frequency Band", value=10, uid=[0], range=None),
desc.IntParam(name="low", label="Low Freq", description="Low Frequency Band", value=0, uid=[0], range=None),
],
description='''Number of contributions per frequency band for multiband blending (each frequency band also contributes to lower bands)''',
advanced=True,
),
ListAttribute
desc.ListAttribute(
name="viewpoints",
elementDesc=desc.GroupAttribute(name="viewpoint", label="Viewpoint", description="", groupDesc=Viewpoint),
label="Viewpoints",
description="Input viewpoints",
group="",
),
DynamicNodeSize
size = desc.DynamicNodeSize('inputFiles')
inputs = [
desc.ListAttribute(
elementDesc=desc.File(
name="input",
label="Input",
description="",
value="",
uid=[0],
),
name="inputFiles",
label="Input Files",
description="Input Files to publish.",
group="",
),
Implementation notes: It is easy to write a node for an existing cli tool, but if you want to contribute your node to the main Meshroom repository, a native Meshroom implementations is required. They can be pure python nodes or c++ implementations on the alicevision side with python cli nodes for Meshroom. This is to ensure multi platform compatibility and reduce dependencies on third parties. Licenses should be compatible with MPL2. Another acceptable implementation for external tools would be to provide a "path to installation" field to link the external tool from within the node.
Meshroom is a GUI for Alicevision
Alicevision is written in C++ and derived from OpenMVG in 2016.
Many OpenMVG features are not (yet) available in Alicevision/Meshroom.