Custom deepstream-test5-app for save object to image file and put path of this image to event message meta

Hello every one
i am working with deepstream-test5-app, my app has two model pgie and sgie with purpose detect object on pgie and classification this object with sgie. i run with multiple source video input and get information by kafka everything working fine.
But now i want to get more object image not only information at kafka.
i had working with some solution:

So i think i need custom deepstream_app.c to get object and put this path to metadata object label.
Everyone can help me, please

• Hardware Platform Jetson
• DeepStream Version 5.0
• JetPack Version 4.4

For custom deepstream_app.c
i was try put pgie_src_pad_buffer_probe() in analytics_done_buf_prob() to extract metadata but get black scream, so where i can put this function ?

In deepstream-app.h i had add

#include "gstnvdsmeta.h"
#include "nvbufsurface.h"
#include "nvds_obj_encode.h"
struct _AppCtx
  gboolean version;
  gboolean cintr;
  gboolean show_bbox_text;
  gboolean seeking;
  gboolean quit;
  gint person_class_id;
  gint car_class_id;
  gint return_value;
  guint index;
  gint active_source_index;

  GMutex app_lock;
  GCond app_cond;

  NvDsPipeline pipeline;
  NvDsConfig config;
  NvDsConfig override_config;
  NvDsInstanceData instance_data[MAX_SOURCE_BINS];
  NvDsC2DContext *c2d_ctx[MAX_MESSAGE_CONSUMERS];
  NvDsAppPerfStructInt perf_struct;
  bbox_generated_callback bbox_generated_post_analytics_cb;
  bbox_generated_callback all_bbox_generated_cb;
  overlay_graphics_callback overlay_graphics_cb;
  NvDsFrameLatencyInfo *latency_info;
  GMutex latency_lock;
  GThread *ota_handler_thread;
  guint ota_inotify_fd;
  guint ota_watch_desc;

  //this is my new add
  NvDsObjEncCtxHandle obj_ctx_handle;

and in deepstream_app.c i has add some code in create_pipeline(…) function:

create_pipeline (AppCtx * appCtx,
    bbox_generated_callback bbox_generated_post_analytics_cb,
    bbox_generated_callback all_bbox_generated_cb, perf_callback perf_cb,
    overlay_graphics_callback overlay_graphics_cb)

  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;

  /***here is my obj_ctx_handle***/
  NvDsObjEncCtxHandle obj_ctx_handle = nvds_obj_enc_create_context();
  if (!obj_ctx_handle)
    goto done;
  appCtx->obj_ctx_handle = obj_ctx_handle;

  if (config->osd_config.num_out_buffers < 8) {
    config->osd_config.num_out_buffers = 8;

  pipeline->pipeline = gst_pipeline_new ("pipeline");
  if (!pipeline->pipeline) {
    NVGSTDS_ERR_MSG_V ("Failed to create pipeline");
    goto done;

So i run make in folder deepstream-app and get an error :

deepstream_app.o: In function `create_pipeline':
deepstream_app.c:(.text+0x33d4): undefined reference to `nvds_obj_enc_create_context'
collect2: error: ld returned 1 exit status
Makefile:60: recipe for target 'deepstream-app' failed
make: *** [deepstream-app] Error 1

Everyone can help me

Per your log, seems it cannot found nvds_obj_enc_create_context, you need to specify the correct path to find the lnvds_batch_jpegenc.

thank you, i was fix it