- The Server loads the plugin’s dynamic library and invokes its entry point function
createNxPlugin()(see i_plugin.h), which returns a pointer to the
- The Server creates an
Engineclass instance by calling
IPlugin::createEngine()using the pointer.
doCreateEngine()virtual method of the interface class (implemented in the helper class
b. This method then calls the virtual method
doObtainEngine()is overridden in the
IPlugin::createEngine()returns a pointer to the
- When a Plugin is enabled for a specific camera in the Desktop Client, the
DeviceAgentclass instance is created.
a. The Desktop Client shows
deviceAgentSettingsModelreturned by the
b. When the “OK” or the “Apply” button is pressed in the Desktop Client, the Server calls
IEngine::obtainDeviceAgent()virtual method of the interface. The
doObtainDeviceAgent()is overridden in the
- The Server provides the plugin with data packets (i.e. video frames).
a. It invokes the
doPushDataPacket()method of the
IConsumingDeviceAgentinterface on retrieval of every frame. It is the general method for all types of Plugins (analytics, video source, storage) and is the only method the Server can execute without accessing external resources.
b. In the Metadata SDK,
doPushDataPacket()virtual method of the interface class (see src/nx/sdk/analytics/i_consuming_device_agent.h). The
doPushDataPacket()is overridden in the
ConsumingDeviceAgenthelper class of the SDK (see src/nx/sdk/analytics/helpers/consuming_device_agent.cpp). The class implements several other methods in order to make plugin development more convenient and efficient:
- When a new frame is retrieved from the camera, the Server simultaneously calls the following methods:
pushUncompressedVideoFrame()to deliver the frame to the plugin;
pullMetadataPackets()to receive metadata from the plugin;
pushMetadataPacket()can be called at any time by the
You can choose either one of the "push" or "pull" paradigms depending on the desired workflow in the Plugin. The differences are:
pushMetadataPacket()is called by the Plugin, while
pullMetadataPackets()is called by the Server.
pushMetadataPacket()expects one metadata packet, while
Currently, the analytics plugin consists of three helper classes, which we recommend using:
Plugin- implemented in plugin.cpp and plugin.h.
Engine- implemented in engine.cpp and engine.h.
DeviceAgent- implemented in device_agent.cpp and device_agent.h.
We recommend reading this article to understand the plugin lifecycle better.
- In this tutorial, we are going to use the
DeviceAgenthelper class and its