Before you begin, read through the commented source code of the sample integration to familiarize yourself with its structure.
Rename the project in CMakeLists.txt
To customize the integration, rename the template targets in the configuration file so it builds with your new integration name.
Open
CMakeLists.txt.Open your editor's Find and Replace panel.
Replace all instances of
samplewithopencv_object_detection.Replace all instances of
SAMPLEwithOPENCV_OBJECT_DETECTION.Save
CMakeLists.txt.
Changing these definitions updates the final project name to opencv_object_detection_analytics_plugin and ensures the resulting library compiles with the correct name.
Verify the new binary name
Rebuild the project.
Run the following command to verify that the binary name has updated:
ls $BUILD_DIRConfirm that
libopencv_object_detection_analytics_plugin.soappears in the output.
Understand the integration structure
The analytics integration relies on three core helper classes:
Integration: Implemented in
integration.cppandintegration.h.Engine: Implemented in
engine.cppandengine.h.DeviceAgent: Implemented in
device_agent.cppanddevice_agent.h.
Each class includes a manifestString() method that returns a JSON string. This manifest defines the integrations attributes, settings, inputs, and outputs.
For more details on available options, see the following resources in the Metadata SDK:
src/nx/sdk/analytics/manifests.md— Detailed manifest options.src/nx/sdk/settings_model.md— Available settings model options.samples/stub_analytics_plugin/— A complete reference example of a manifest implementation.
Update the integration manifest
Modify the integration manifest so the correct name displays in the Desktop Client.
Open
integration.cpp.Locate the
manifestString()method.Replace the method implementation with the following C++ code:
std::string integration::manifestString() const
{
return /*suppress newline*/ 1 + R"json(
{
"id": "sample.opencv_object_detection",
"name": "OpenCV object detection",
"description": ")json"
"This integration is for object detection and tracking. It's based on OpenCV."R"json(",
"version": "1.0.0",
"vendor": "Sample Inc."
}
)json";
}| NOTE: The manifest uses C++ raw string literals (R"json(...)json") to preserve the JSON quotation marks. Because the description spans multiple lines, the raw string literal closes, concatenates with the description string, and then reopens. |
To learn more about these specific manifest parameters, see the comments inside integration.cpp.
Deploy and test the integration
Deploy the newly compiled integration to your server to verify the changes.
Rebuild the integration project.
Remove the old integration binary and copy the new one to the server's plugin directory:
sudo rm $SERVER_DIR/bin/plugins/libsample_analytics_plugin.sosudo cp $BUILD_DIR/libopencv_object_detection_analytics_plugin.so $SERVER_DIR/bin/plugins/Restart the Server and the Desktop Client.
Open Camera Settings in the Desktop Client to confirm that the integration loads successfully with its new name.
Comments
0 comments
Article is closed for comments.