In Deepstream application, how to send a frame as image to kafka?

• Hardware Platform : dGPU
• DeepStream Version : 6.2
• Language : c++

The question can be seperated as -

  1. How to get the frame as image data? (numpy array or others)
  2. How to send that image to kafka?

For no.1, I want something in c++ similar to the below python example -

n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
frame_copy = np.array(n_frame, copy=True, order='C')
1 Like
  1. please refer to How to get numpy array frame from deepstream 5.
  2. please refer to How to save frame as jpg and send the filename to kafka in deepstream 5.0 deepstream_test5
  1. I want the no 1 in c++.
  2. I do not want to save the image as jpg. I do not want to send the filename, instead I want to send the image to kafka.

Isn’t there any way to get the image data in any format in c++? (not saving as jpg to disk)

  1. please refer to this DeepStream SDK FAQ - #17 by mchi, you can save the data into buffer or disk.
  2. please refer to this How to add custom data to analytics or send data via kafka inside deep stream, you can ad jpg as a extra information.

Okay,
nvds_obj_enc_process (ctx, &frameData, ip_surf, NULL, frame_meta); This function save the image as jpg right? Without saving to disk how can I send the image to kafka?

NvDsObjEncUsrArgs 's attachUsrMeta can save jpg data as usermeta, please refer to sample \opt\nvidia\deepstream\deepstream-6.2\sources\apps\sample_apps\deepstream-image-meta-test\deepstream_image_meta_test.c, it can save and access jpg data in usermeta. then you can use this method add custom data to send.

Okay, thank you. I will try.

the example deepstream_image_meta_test.c is a .c file. I followed every steps in my .cpp file and I get the following error in compilation

error: invalid conversion from ‘gpointer’ {aka ‘void*’} to ‘NvDsObjEncCtxHandle’ {aka ‘_NvDsObjEncCtx*’} [-fpermissive]
 1215 |         nvds_obj_enc_process(ctx, &objData, ip_surf, obj_meta, frame_meta);
      |                              ^~~
      |                              |
      |                              gpointer {aka void*}

please create NvDsObjEncCtxHandle by nvds_obj_enc_create_context and pass it to probe function by gst_pad_add_probe (pgie_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
pgie_src_pad_buffer_probe, (gpointer) obj_ctx_handle, NULL);

yes I have done it. Followed everything but still the same. I have seen a similar topic where the error is same - Try to send custom nvdsanalytics result to kafka, but message meta copy func compile failed
but the solution is not clear

the error is related to NvDsObjEncCtxHandle, please try this
nvds_obj_enc_process((NvDsObjEncCtxHandle )ctx…

Thanks the error solved. Also, libjpeg-dev is a dependency which is not mentioned in readme.
Now regarding the original question,

nvds_obj_enc_process((NvDsObjEncCtxHandle)ctx, &objData, ip_surf, obj_meta, frame_meta);

this function is saving a lot of images to the disk. probably 60/s. I don’t want it to save on disk, instead send to kafka. looks like there is no way to get the image data before nvds_obj_enc_process(ctx, &objData, ip_surf, obj_meta, frame_meta); this function.

please refer to NvDsObjEncUsrArgs’s saveImg, which represents “Boolean variable to save image”.

I see, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.