- The Server loads the plugin’s dynamic library and invokes its entry point function
createNxPlugin()
(see i_plugin.h), which returns a pointer to thenx::sdk::IPlugin
interface instance. - The Server creates an
Engine
class instance by callingIPlugin::createEngine()
using the pointer.
a.createEngine()
calls thedoCreateEngine()
virtual method of the interface class (implemented in the helper classPlugin
.
b. This method then calls the virtual methoddoObtainEngine()
. ThedoObtainEngine()
is overridden in thePlugin
helper class.
c. TheIPlugin::createEngine()
returns a pointer to theIEngine
interface instance. - When a Plugin is enabled for a specific camera in the Desktop Client, the
DeviceAgent
class instance is created.
a. The Desktop Client showsdeviceAgentSettingsModel
returned by theEngine::manifestString()
method.
b. When the “OK” or the “Apply” button is pressed in the Desktop Client, the Server callsIEngine::obtainDeviceAgent()
virtual method of the interface. ThedoObtainDeviceAgent()
is overridden in theEngine
helper class.
c. TheIEngine::obtainDeviceAgent()
calls thedoObtainDeviceAgent()
virtual method - The Server provides the plugin with data packets (i.e. video frames).
a. It invokes thedoPushDataPacket()
method of theIConsumingDeviceAgent
interface 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,pushDataPacket
invokes thedoPushDataPacket()
virtual method of the interface class (see src/nx/sdk/analytics/i_consuming_device_agent.h). ThedoPushDataPacket()
is overridden in theConsumingDeviceAgent
helper 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:pushCompressedVideoFrame()
,pushUncompressedVideoFrame()
,pullMetadataPackets()
,pushMetadataPacket()
, etc. - When a new frame is retrieved from the camera, the Server simultaneously calls the following methods:
a.pushUncompressedFrame()
orpushUncompressedVideoFrame()
to deliver the frame to the plugin;
b.pullMetadataPackets()
to receive metadata from the plugin; -
pushMetadataPacket()
can be called at any time by theDeviceAgent
.
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, whilepullMetadataPackets()
is called by the Server. -
pushMetadataPacket()
expects one metadata packet, whilepullMetadataPackets()
expects astd::vector
of them.
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
DeviceAgent
helper class and itspushUncompressedFrame
andpushMetadataPacket
methods.
Comments
0 comments
Article is closed for comments.