string and array type tool input/output
I'm learning to create plugin tools.
How can I have string type input, eg. file path as input? Do I have to use arrays?
And how to use an array type of output?
To declare an input parameter as a string, you can say e.g.
FIXED_INPUT(kuvio_string, fileName, ""). Your function will receive the string as a UTF-8-encoded
The only way to create dynamically typed arrays from C is currently kuvio_array_from_json. Dynamically typed arrays aren't really intended to be used in processing. Few tools can actually make use of them, Script being perhaps the only useful one.
If you want to output an array of numbers or Boolean values, the correct data type to use is a matrix. For example, the ConvexHull tool in the OpenCv example plugin declares a matrix output:
OUTPUT(kuvio_fmatrix, hull). The convention is to use a 1×N matrix if you need to output a vector of numbers.
@Topi thanks for the answer.
FIXED_INPUT(kuvio_string, fileName, "") is pretty much how I figured out it would go. The problem is that VisionAppster Builder won't start with that string declaration. If I remove the declaration, VA Builder runs and the plugin is available.
What could be the problem? I'm using VA-builder 2.8.2 on Win 10 and mingw64 compiler with makefile (exampletoolplugin from examples).
I can confirm that this really is the case. In fact, adding that declaration seems to cause a crash. This is undoubtedly a bug we need to investigate more. Thanks for reporting.
For the time being, you need to find a work-around for example by using a matrix as input. It is definitely not convenient, but at the bottom, strings are just sequences of numbers.
A fix to this bug will be included in the next release (2.9).