C++ Extensions

Develop high-performance CamiTK extensions in C++.

Getting Started with C++ Extensions

C++ extensions are ideal for performance-critical tasks. DevStudio generates all the files required to add your extension into CamiTK.

Steps to Create a C++ Extension:

  1. Open DevStudio from the CamiTK menu.
  2. Define your extension's name, parameters, and input components.
  3. Choose between Hotplug or Standard extension types.
  4. DevStudio generates the boilerplate code: one C++ files per action for you to complete, a .camitk file containing the metadata of your extension, and a CMakeLists.txt ready to build your code.
  5. As shown in the devstudio video click on Initialize to automatically build your extension for the first time and then on Register to integrate it in CamiTK (it will then be automatically available in the corresponding Action menu).
  6. Complete the generated C++ classes and rebuild to modify your extension.

C++ Action code template

When DevStudio generates the template code of an action, it generates a class derived from CamiTK Action in the corresponding .cpp files (the header file is generated, if you need to add fields to your class use the DevStudio UI or edit the .camitk directly). There are four methods you will need to complete. Some C++ code is generated when DevStudio creates your action for the first time to show you an example of what is expected. It is now up to you to modify the four methods:

  • init is automatically called when the extension is loaded by CamiTK. Modify it to enter code to initialize fields, state variables, or open connection to a device.
  • targetDefined is run when the user changes the input data (called target in an action) in the interface by selecting a component and then click on your action to trigger it. Use this if you need to update the action state/fields depending on the input data.
  • parameterChanged is run when a parameter value is modified is the GUI automatically generated from your action parameters you added in DevStudio. Use this if you need to update the action state/fields depending on the input parameters.
  • process this is the main code, run when the user clicks on the Apply button. This is where you write the C++ code that details your data processing.

Check the API and tutorials to see what is possible and some examples.


Hotplug vs. Standard Extensions

Choose Your Extension Type

Standard Extension

Pros: Fully supported integration, distributed as a library (.so/.dll).
Cons: Requires a CamiTK restart to reload.

Hotplug Extension

Pros: Dynamically reloaded while CamiTK is running.
Cons: ⚠ Very experimental, users need a compiler and development environment.


C++ API Documentation

C++ API Documentation

The CamiTK C++ API provides full access to CamiTK's core functionality. Explore the full documentation:


C++ Tutorials

Tutorials

Learn by example! Check out our **C++ extension tutorials** to understand how to:

  • Create a custom Component.
  • Develop an Action for image processing.
  • Build a Viewer for 3D visualization.

Testing with QTest and CamiTK test framework

Testing

We recommend to check CamiTK automatic test framework for easily adding automatic integration tests and/or to use QTest to write unit tests for your C++ extensions. Testing ensures your extensions are reliable and maintainable.

Tutorials for testing are coming soon!

Learn more…