Python script (descriptor)

On a Windows machine, you need to install Python version 3 or higher and the py Python launcher

First select Descriptor as node type and then select Python script as the method. Select the python script file using the Browse button or type the path to the script file directly.

Parameters

Python file

Select the python file.

Python interpreter (optional)

Select a custom interpreter executable, empty will use py on Windows and python command on Linux and macOS.

Type

  • Object

    • Applies the python file content on the objects.

  • Pixels

    • Applies the python file content on the pixels.

Simple python script for a descriptor

Python
def perform(frame_data):
    count = len(frame_data)

    if count == 0:
        return [0.0]

    tot_sum = sum(frame_data)

    return [tot_sum / count]

Example input to the script

Data is streamed directly into the Python script's memory. The frame_data input is a contiguous, flat 1D array of floats containing all spectral bands for all pixels provided to the descriptor.

For a single pixel with two bands, the raw input array looks like this:

[1.0, 1.5]

Because this specific script calculates a global average across all data points regardless of spatial dimensions, the num_bands parameter is not required in the function signature.

Optional setup method

If your script requires one-time initialization—such as loading an external machine learning model, pre-calculating a reference vector, or setting up static variables—you can define an optional setup function.

Breeze will execute the setup function exactly once when the workflow initializes, before any data is streamed to the perform function. This prevents heavy initialization code from running repeatedly during high-speed real-time execution.

To share variables between the setup and perform functions, declare them at the root level of your script and use the global keyword inside setup.

Python
calibration_factor = 0.0

def setup():
    global calibration_factor
    
    calibration_factor = 1.25

def perform(frame_data):
    count = len(frame_data)

    if count == 0:
        return [0.0]

    tot_sum = sum(frame_data)
    adjusted_sum = tot_sum * calibration_factor

    return [adjusted_sum / count]
  

Example output from the script

Your script simply returns a standard Python list from the perform function containing your calculated descriptor value(s).

[1.25]

Migrating from Breeze older than 2026.1

If you are updating an older descriptor script that used file parsing, you must align it with the new memory stream format.

  • Remove file reading: Do not import sys, read sys.argv, or open temporary text files.

  • Wrap your logic: Place your code inside a def perform(frame_data): function.

  • Return, do not print: Return your final list directly from the function instead of using print(result).

  • Update array access: The data is already formatted as an array of floats. You no longer need to loop through text rows and split strings by semicolons. Exceptions and error formatting are now handled automatically by the system wrapper.