VAT  3.0
Video Analysis Tool
How to develop new modules

To create a module and to allow the application to recognize this module, there's some rules of development and registration that should be followed. As an example of module creation, here are the steps for a simple module.

Firstly

Create a new class at MODULES directory. This class should inherit from ModuleInterface class and implement some virtual methods. Here is an example of a Module class with those methods to implement:

class NewModule : public ModuleInterface {
public:
NewModule(Datapool* i_data);
~NewModule();
bool setParameters(QDomNode& config);
bool init();
bool run();
bool updateParameters();
};

As you can see, This class has public inheritance from ModuleInterface. This interface comes with the methods: setParameters, init, run and updateParameters. The purpose of Constructor and each one of these methods are shown below:

  1. NewModule(Datapool* i_data)
    It's recomended to link i_data to inherited attribute m_data in this constructor. To do this, you can implement constructor in this way (in NewModule.cpp file):
    NewModule::NewModule(Datapool *i_data):ModuleInterface(i_data) {
    //...
    }
  2. bool setParameters(QDomNode& config)
    This method was meant to read each parameter given by xml configuration file (specifically: default_config.xml file).
  3. bool init()
    This method was meant to take the read parameters and configure the module by its default. It is called after setParameters.
  4. bool run()
    This method was meant to execute the main task of the module. It is called at each frame.
  5. bool updateParameters()
    This method was meant to change parameters of module according to user specification at runtime. It is called at user request.

Secondly

The created class must be registrated. To do this, It's necesary to add the following lines at modules.cpp file:

  1. #include "MODULES/NewModule.h"
    This is actually the inclusion of module header. This should be put at the end of include tags list.
  2. ADD_MODULE(NewModule)
    This macro is used to allocate the module to be accessible by application. This should be put at the end of the ADD_MODULE list.
  3. REGISTER_MODULE(NewModule, MODULE_TYPE);
    This macro is used to inform the existance of this module to VideoAnalysis class. In MODULE_TYPE you have to specify the type of module which could be one of the following: ACQUISITION, INITIALIZATION, SEGMENTATION, TRACKING, ANALYSIS or OTHER.

Finally

A module configuration node must be created. This configuration is, by default, at config/default_config.xml file. As an example of node to add:

1 <NewModule>
2  <typeOfCamera value="LocalCamera">
3  <deviceID value="0" />
4  </typeOfCamera>
5 </NewModule>

In this example we are supposing that the module "NewModule" needs configuration for typeOfCamera as "LocalCamera" and for this camera is a parameter devideID with value "0".