Plugin API

The API doc manual can be found here.
There are two requirements for XIMEA CamTool plugins to be detected and loaded at startup:

  1. There has to be exactly one class in the project, that derives from QObject and CxPlugin, and also declares Q_OBJECT, Q_PLUGIN_METADATA and Q_INTERFACES(CxPlugin) in its header.
  2. The compiled library file name must have "xvp" prefix.
    Application loads all plugins at startup after all cameras are connected.

Plugin can use all exported functions and classes present in xiCore library. The plugin may communicate with several items in the application itself by using class IxAppDelegate.
The task for the CxPlugin class is to add new possibilities to the application. It means register new processing objects, or add new docked windows and other GUI objects. All this registration has be done in CxPlugin::init method.

Correct minimal header file for the main plugin class may look like:

#include <Plugin.h>
#include <QObject>
class MyPlugin : public QObject, public CxPlugin
    Q_PLUGIN_METADATA(IID "com.example.MyPlugin")
    virtual bool init();

Plugins with GUI

Plugin can create additional GUI in the application. Everything is done using Qt Widgets library.
  • To add a toolbar button, add a QAction to IxAppDelegate::mainToolbar
  • To add a new menu popup, add a QAction to menu at IxAppDelegate::mainWindow
  • To add a new docked window, use IxAppDelegate::addDockedWidget
    Please see Mean Gray Measurement for an example.

All available docked windows are listed in View menu in the application

Object for the processing chain

Any type of image processing can be added to the application. For example contrast enhancement, edge detection, custom denoising. The implementation is again very similar to file format plugin, but you derive from CxChainable.

To register it to the system, call the following in the plugin CxPlugin::init method:

xiRTTI_REGISTER(MyImageProcessing, "CxChainable"); 

There are lots of functions available to override in CxChainable, but most of them can be left with default implementation. Please see CxNegativeChnbl for a simple example.
New processing chain objects automatically appear in Processing Chain Editor window, under '+' button. The name of the object is set in Q_CLASSINFO

Some minimal header file for the processing chain object may look like this:

#include <Chainable.h>
class MyProcessingChnbl : public CxImageProvider
    Q_CLASSINFO("CustomName", "My Processing")
    Q_INVOKABLE MyProcessingChnbl();    // constructor must be 
                                        // marked as invokable
    virtual QString title() const;    
    virtual bool acceptsDataFrom(CxChainable *pPrecedessor);
    virtual int buffersCountInMemoryPool() const;
    virtual CxChainable* clone();
    virtual IxChainData* processData(IxChainData *pReceivedData);
    // CxImageProvider
    virtual bool queryOutputImageInfo(const SxPicBufInfo &picInfoInput, 
SxPicBufInfo &picInfoOutput);

File format implementation

You can add the support for new file formats using a plugin. The key is to implement class derived from IxImageDataLoader or IxImageDataSaver.

To register it to the system, call the following in plugin CxPlugin::init method.

xiRTTI_REGISTER(MyDataLoader, "IxImageDataLoader"); 

Please note that you can implement and register more xiRTTI classes in a single plugin.

If you fill all necessary functions, the new file format option automatically appears in application's File - Open and File - Save dialog windows.

Header file for the loader may look like this:

#include <DataLoader.h>
class MyDataLoader : public QObject, public IxImageDataLoader
    Q_INVOKABLE MyDataLoader();    // constructor must be marked as invokable
    // IxChainDataLoader interface
    virtual qint32 sequenceSize();
    virtual IxChainData *loadedData(qint32 iSeqIdx = 0);
    virtual bool load();
    virtual QString inputFile();
    virtual void setInputFile(const QString &sFileName);
    // IxImageDataLoader interface
    virtual double loadedFps();
    virtual TxImageFormatList supportedImageFormats();