Tutorial 04

February 26, 2026 · View on GitHub

What you will learn

  • When to use desc.CommandLineNode vs desc.Node
  • How commandLine and {allParams} work
  • How to write an external processing script
  • The group mechanism for including/excluding parameters from the command line

Prerequisites

When to use CommandLineNode

Use desc.CommandLineNode when:

  • Your processing logic lives in a standalone script or binary.
  • You want process isolation (separate memory space, separate dependencies).
  • You are wrapping an existing CLI tool.

Use desc.Node when:

  • Your logic is tightly integrated with Meshroom (needs chunk, logManager, etc.).
  • You need fine-grained control over the execution flow.

The commandLine attribute

class HelloCommandLine(desc.CommandLineNode):
    commandLine = "python " + str(
        Path(__file__).parent.parent.parent / "scripts" / "hello_process.py"
    ) + " {allParams}"
  • Path(__file__) resolves to the node's .py file. We navigate up to the plugin root, then into scripts/.
  • {allParams} is replaced by all parameters that have group="allParams", formatted as --name value pairs.

For example, with these inputs:

--input /path/to/image.jpg --brightness 20 --contrast 1.5 --outputPath /path/to/output.jpg

The group mechanism

desc.IntParam(
    name="brightness",
    ...
    group="allParams",  # Included in {allParams}
)

desc.ChoiceParam(
    name="verboseLevel",
    ...
    group="",  # Excluded from {allParams}
)
  • group="allParams" — the parameter is included in {allParams} expansion.
  • group="" — the parameter is excluded from the command line.

Important: The output path must also be in group="allParams" so the script knows where to write its result. This is the standard pattern in mrRoma and mrVideoUtils.

No processChunk needed

desc.CommandLineNode does not have a processChunk method. Meshroom handles:

  1. Building the command from commandLine and parameter substitution.
  2. Executing it as a subprocess.
  3. Capturing stdout/stderr for the node's log.

Writing the external script

scripts/hello_process.py is a standard Python script:

import argparse
import sys

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--input", required=True)
    parser.add_argument("--brightness", type=int, default=0)
    parser.add_argument("--contrast", type=float, default=1.0)
    parser.add_argument("--outputPath", required=True)
    args = parser.parse_args()

    import cv2
    image = cv2.imread(args.input)
    # ... process image ...
    cv2.imwrite(args.outputPath, result)

if __name__ == "__main__":
    main()

The argument names must match the name attributes of the node's parameters with group="allParams".

How to test it

A pre-configured project is available: open meshroom/tuto04-hello-command-line.mg in Meshroom (make sure you have run scripts/setup_projects.sh first). Or set it up manually:

  1. Add a HelloCommandLine node to your graph.
  2. Set the Input Image field to the path of your test image. For this tutorial, we use the Meshroom logo hello-world-mrlogo.png:
Input image: Meshroom logo
  1. Adjust Brightness and Contrast parameters.
  2. Click Compute.
  3. To view the output in the 2D viewer, double-click on the node or use the dropdown menu at the bottom of the 2D viewer and select Output Image.
  4. Check the node's log to see the exact command line that was executed.
  5. The output should show the image with adjusted brightness and contrast.

HelloCommandLine

Expected result

The output image has brightness and contrast adjusted according to the parameters. The processing was done by the external script, not by the node itself.