How to write plugins
In roviz, all items you see in the application are in fact plugins. If you want to write your own plugin, you can execute the new_project.sh script. You only need to provide it with a class name for your new item and it should automatically create a plugin based on a template for you. We’ll shortly go through the most important concepts that you need to know for writing a plugin:
- Inputs/Outputs: Every plugin has inputs and outputs. An item will receive data from its inputs, process it and push it out to its outputs. Use
this->addInput and this->addOutput to add new inputs and outputs. See RovizItem::addInput, RovizItem::addOutput, Input and Output for more information.
- Config: Every plugin can have several configs. Use
this->addConfig to add a new config. See the documentation of RovizItem::addConfig and Config for more information.
- Trim: You can also have trim values that will be modifyable on-the-fly with sliders. Use
this->addTrim to add a Trim. See RovizItem::addTrim and Trim for more information.
- thread: Every plugin must implement the thread function. This function will be started in a new thread once the item is started. This is where most of your code should be. Make sure you properly use RovizItem::wait, RovizItem::waitFor, RovizItem::waitForCond, Input::waitForInput, or RovizItem::running! They make sure that the start/pause/stop mechanism works properly. See their documentation to find out which one to use in which situation.
- starting: If you do any initialization apart from Inputs/Outputs, Configs and Trims, you should do it in a function called starting that will be called before thread and not in the constructor to make sure the item has a clean state every time it gets re-run.
- Image: The most important class for image processing plugins. Use Output::pushOut to push out images and pass them to the next item. DO NOT MODIFY THE IMAGE DATA AFTER YOU PUSHED IT OUT! roviz does never copy image data for performance reasons, so you must not access the memory of the image once its pushed out, as the following items of the pipeline will use the same memory location. There are also other types available that can be pushed out. Currently, the following are available:
Once you’ve finished writing your plugin, just run qmake and make again in the root folder and your plugin should build.