Skip to content

2 DevDoc

natowi edited this page Feb 12, 2020 · 21 revisions

Implementing new nodes

Here are the basics on how to implement new nodes:

  1. 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 only supported by alicevision plugins.

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

  1. 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)

(https://github.com/alicevision/meshroom/blob/develop/meshroom/nodes/aliceVision/CameraInit.py)

GUI elements

References on different supported GUI elements for nodes can be found here

Meshroom default nodes support the following GUI elements:

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="",
        ),

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.

About

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.

Clone this wiki locally