Feature Request: Runtime Analytics Configuration Management in DeepStream

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
GPU
• DeepStream Version
7.1
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
new requirements
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

  1. Runtime Reload for nvdsanalytics
  • Implement dynamic configuration reload capability for nvdsanalytics plugin
  • Enable modification of analytics rules without pipeline restart
  • Support hot-reload of configuration files during runtime execution
  • Allow seamless updates when sources are added/removed via nvmultiurisrcbin
  1. REST API Integration
  • Add new endpoints to nvds_rest_server for nvdsanalytics management
  • Proposed endpoints:
    • GET /analytics/config - Retrieve current configuration
    • PUT /analytics/config - Update configuration
    • POST /analytics/reload - Trigger configuration reload
  • Support JSON payload for configuration updates
  • Return appropriate HTTP status codes for operation results

Technical Benefits:

  • Enhanced system flexibility for dynamic deployments
  • Reduced downtime during configuration changes
  • Improved integration between pipeline components
  • Programmatic control over analytics parameters

Use Case: Dynamic camera management scenarios where analytics rules need modification based on source changes, without impacting the running pipeline.

Are these requirements for any product of any company? What is the use case?

Yes, this is for developing products for highway/road infrastructure companies.

Currently, we use deepstream/triton-server across multiple servers with L40 and A10 GPUs.

We’re migrating from deepstream 6.3 to 7.1, using nvmultiurisrcbin with REST API instead of the old uridecodebin > streamux method.

Our system works with preset-enabled cameras that automatically change positions at set intervals to monitor different angles. For example, Position 1 might monitor a highway entrance for 30 seconds, then switch to Position 2 monitoring an exit for 30 seconds, and so on.

I use nvdsanalytics for pre-analytics (line-crossing/ROI/object_status). While nvdsanalytics doesn’t officially support runtime configuration changes, @fanzh helped implement this, which is currently in production.

We’re designing a more dynamic environment where multiple containers start, and an external system initiates streams and configures nvdsanalytics in runtime via REST API.

Since nvdsanalytics hasn’t kept pace with nvmultiurisrcbin’s advances, I face a challenge: when running a pipeline and removing/adding a camera stream, how to reload nvdsanalytics without impacting the entire environment?

Currently, I can build an external API to modify reload-cfg configurations.

Two key reasons for needing this feature:

  1. Runtime camera addition/removal via REST API becomes impractical with nvdsanalytics since the entire pipeline needs restarting whenever a camera is added.
  2. With multiple presets, reconfiguring analytics for new positioning or ROI recalibration requires stopping the entire pipeline (affecting all cameras for a single change).

This feature would help manage dynamic camera configurations and preset changes and roi recalibration more efficiently.

For now I’ll try to implement it in nvmultisrcbin using the documentation . But I believe the community will appreciate if this is integrated.

Thank you for following up on this feature request. I wanted to let you know that I’ve already implemented a working solution for runtime analytics configuration updates.

The implementation enables configuration reloading through a REST API endpoint without pipeline restart. I modified the following DeepStream components:

  • gstnvdscustomhelper
  • nvds_rest_server
  • gst-nvmultiurisrcbin
  • gst-nvdsanalytics

The feature allows runtime configuration updates through a REST API endpoint:

Example Request:

curl -XPOST 'http://localhost:9000/api/v1/analytics/reload-cfg' -d '{
"stream":
  {
      "stream_id":"0",
      "reload_cfg":1
  }
}'

Successful Response:

{
    "reason" : "RELOAD_CFG_UPDATE_SUCCESS",
    "status" : "HTTP/1.1 200 OK"
}

Server Logs:

uri:/api/v1/analytics/reload-cfg
method:POST
Setting reload_cfg flag to trigger configuration reload
nvdsanalytics->reload_cfg:1, ready to reload configuration file
Successfully reloaded analytics configuration

The solution works as expected, providing:

  • Thread-safe configuration updates
  • REST API interface
  • Support for both YAML and standard config files
  • No pipeline restart required

While I’ve moved forward with my own implementation, I believe this functionality could be valuable for the DeepStream community if integrated into the official release.

Best regards

Thank you for your contribution to improve the DeepStream functions! Is it possible for you to share your changes to us? We can review the changes and consider to add the changes into DeepStream SDK.

@Fiona.Chen

Implemented Changes

Feat:

  1. Added runtime configuration reload capability for nvdsanalytics
  2. Enhanced gst-nvmultiurisrcbin API (/api/v1/stream/get-stream-info) with two new fields:
    • stream_id
    • camera_url
  3. Implemented API in nvds_rest_server for nvdsanalytics reload_cfg functionality

Implementation Details

Please find attached the git diff files showing the changes implemented.

Technical Debt

The current implementation needs some refactoring work to improve code quality:

  • Function names should be standardized to follow the project’s naming conventions
  • Some methods could be restructured for better maintainability

Suggested Improvements

I would like to propose two additional features that could enhance this implementation:

  1. Add a new GET API endpoint to identify the configuration file location of nvdsanalytics
  2. Enable configuration reload by allowing users to specify a new CFG file.

feat_api_reload_nvdsanalytics.zip (8.3 KB)

Thank you for the sharing! We will review your patch first.

Key changes:

  1. Removed duplicate reload logic
  2. Only sets reload_cfg flag for transform_ip to handle
  3. Maintains event chain handling
static gboolean
gst_nvdsanalytics_sink_event (GstBaseTransform * trans, GstEvent * event)
{
 GstNvDsAnalytics *nvdsanalytics = GST_NVDSANALYTICS (trans);

 if ((GstNvDsCustomEventType) GST_EVENT_TYPE (event) ==
     GST_NVEVENT_ANALYTICS_RELOAD_CFG_UPDATE) {
   gchar *stream_id = NULL;
   guint reload_flag = 0;

   gst_nvevent_parse_analytics_reload_cfg_update (event, &stream_id, &reload_flag);

   if (reload_flag) {
     nvdsanalytics->reload_cfg = TRUE;
   }
 }

 return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
}