C++ Extensions
Use C++ for high-performance extensions, such as computationally intensive tasks.
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:
- Open DevStudio from the CamiTK menu.
- Define your extension's name, parameters, and input components.
- Choose between Hotplug or Standard extension types.
- DevStudio generates the boilerplate code: one C++ files per action for you to complete, a
.camitkfile containing the metadata of your extension, and aCMakeLists.txtready to build your code. - 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).
- 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:
initis 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.targetDefinedis 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.parameterChangedis 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.processthis 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
Unless you would like to contribute by testing and providing some feedback, we do not recommend to create Hotplug extension for now as it is still a technological preview and very experimental.
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.