Save Image with Bounding Boxes

P

GPU (NVIDIA RTX 5090)


Operating System:

Ubuntu 24.04


DeepStream Version:

8.0


CUDA Version:

12.8


TensorRT Version:

10.9


NVIDIA GPU Driver Version:

570.133


Issue Type:

I am using deepstream_app.c and added a probe at analytics_done_buf_probe to save images.
Currently, I can save the frame image, but I need to save the image with bounding boxes drawn on it.
Please suggest the simplest way to draw and save bounding boxes on the image.


How to Reproduce the Issue:

  1. Use the DeepStream sample application (deepstream-app).

  2. Modify deepstream_app.c to add a probe at analytics_done_buf_probe.

  3. Save images from the probe.

  4. Need help on how to include bounding boxes while saving the image.


Expected Result:

Saved images should include bounding boxes for all detected objects.

1 Like

I think if your probe is after the OSD and drawing is enabled for OSD then you should have the images with bboxes drawn already. Can try to put it at the srcpad of nvdsosd and see

I think this reply is the correct answer. For deepstream-app, consider modifying all_bbox_generated_cb in deepstream_app.c, refer to this code snippet.

 appCtx->all_bbox_generated_cb = all_bbox_generated_cb;
  appCtx->bbox_generated_post_analytics_cb = bbox_generated_post_analytics_cb;
  appCtx->overlay_graphics_cb = overlay_graphics_cb;

I have implemented the callbacks in deepstream_app.c as shown below:

appCtx->all_bbox_generated_cb = all_bbox_generated_cb;
appCtx->bbox_generated_post_analytics_cb = bbox_generated_post_analytics_cb;
appCtx->overlay_graphics_cb = overlay_graphics_cb;

Now I want to save images with bounding boxes, but I’m facing an issue — all camera streams appear as one, and the object ID is always 0.

I only want to draw bounding boxes from the secondary model detection on the full frame.

Is this possible in deepstream-app, and how can I achieve it?

You may need to add nvstreamdemux in the configuration file. For deepstream, all streams will be batched for inference. If you need to use nvstreamdemux to split the batch into streams

If there is no nvtracker in the pipeline,obj_meta->object_id should be UNTRACKED_OBJECT_ID (0xFFFFFFFFFFFFFFFF), not 0.

Please refer to the following function in deepstream_app.c calling process

/**
 * Probe function to get results after all inferences(Primary + Secondary)
 * are done. This will be just before OSD or sink (in case OSD is disabled).
 */
static GstPadProbeReturn
gie_processing_done_buf_prob (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *) info->data;
  NvDsInstanceBin *bin = (NvDsInstanceBin *) u_data;
  guint index = bin->index;
  AppCtx *appCtx = bin->appCtx;

  if (gst_buffer_is_writable (buf))
    process_buffer (buf, appCtx, index);
  return GST_PAD_PROBE_OK;
}

sorry for misunderstanding not unique object id,i have same frame id for each camera as 0.

Do you mean frame_meta->source_id?

yes,i mention that

Sorry for delay.Is this still an issue that requires support?