When I get an error when I use deepstream's NvDsDisplayMeta, I don't know where the problem is

error :corrupted size vs. prev_size while consolidating Aborted (core dumped)

mycode:

static GstPadProbeReturn
nvinfer_src_pad_buffer_probe1 (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{

GstBuffer *buf = (GstBuffer *) info->data;
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
NvDsMetaList * l_frame = NULL;

NvDsMetaList * l_obj = NULL;
NvDsObjectMeta *obj_meta = NULL;

// Get original raw data
GstMapInfo in_map_info;
if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
g_print (“Error: Failed to map gst buffer\n”);
gst_buffer_unmap (buf, &in_map_info);
return GST_PAD_PROBE_OK;
}

char* src_data = NULL;
NvBufSurface *surface = (NvBufSurface *)in_map_info.data;
int conunt=0;
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next)
{
//图像转换
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
if (!frame_meta)
continue;

  guint height = surface->surfaceList[frame_meta->batch_id].height;
  guint width = surface->surfaceList[frame_meta->batch_id].width;
  cudaMalloc((void**)&src_data,surface->surfaceList[frame_meta->batch_id].dataSize);
  cudaMemcpy((void*)src_data,(void*)surface->surfaceList[frame_meta->batch_id].dataPtr,surface->surfaceList[frame_meta->batch_id].dataSize,cudaMemcpyDeviceToDevice);  
  cv::cuda::GpuMat nv12_mat=cv::cuda::GpuMat(height, width, CV_8UC4, src_data,surface->surfaceList[frame_meta->batch_id].pitch);
  cv::cuda::GpuMat nv12_mat_out=cv::cuda::GpuMat(height, width, CV_8UC4);
  cv::cuda::resize(nv12_mat, nv12_mat, cv::Size(512,512 ));
  cv::Rect area_new = cv::Rect(512, 0,512, 512);
  nv12_mat.copyTo(nv12_mat_out(area_new));
  cudaMemcpy((void*)surface->surfaceList[frame_meta->batch_id].dataPtr,(void*)nv12_mat_out.data,surface->surfaceList[frame_meta->batch_id].dataSize,cudaMemcpyDeviceToDevice);
  
  ///
  //cv::Mat cpu_Mat;
 // nv12_mat_out.download(cpu_Mat);
  //
  if(src_data != NULL)
  {
    cudaFree(src_data);
    src_data = NULL;
  }
  //图像转换 ---
  
  //渲染的设置  
  NvDsDisplayMeta *disp_meta = NULL;
  if (!disp_meta) {
     disp_meta = nvds_acquire_display_meta_from_pool(batch_meta);
     disp_meta->num_lines = 0;
  } //申请空间
    //首先画一个固定的框图  限定一个区域
  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =512;
  disp_meta->line_params[disp_meta->num_lines].y2 =0;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  

  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =0;
  disp_meta->line_params[disp_meta->num_lines].y2 =512;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  
  
  disp_meta->line_params[disp_meta->num_lines].x1 =512;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =512;
  disp_meta->line_params[disp_meta->num_lines].y2 =512;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  

  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =512;
  disp_meta->line_params[disp_meta->num_lines].x2 =512;
  disp_meta->line_params[disp_meta->num_lines].y2 =512;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;

  for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;l_obj = l_obj->next)
  {
  obj_meta = (NvDsObjectMeta *) (l_obj->data);
  if (!obj_meta)
    continue;
    
  for (NvDsMetaList * l_user = obj_meta->obj_user_meta_list; l_user != NULL;
      l_user = l_user->next) 
   {
    NvDsUserMeta *user_meta = (NvDsUserMeta *)l_user->data;
    if(user_meta->base_meta.meta_type == (NvDsMetaType) NVDS_USER_JARVIS_META_PYVA) 
    {
     NvDsPyvaMetaData *PYVA_meta =
          (NvDsPyvaMetaData *) user_meta->user_meta_data; 
                   
    conunt=conunt+1;
    //大致的渲染结果      
    float x_center=PYVA_meta->x_center;
    float y_center=PYVA_meta->y_center;
    float width=PYVA_meta->width;  //0
    float height=PYVA_meta->height;//1
    
    
    float xtl=256-(y_center-height/2)/80*512;//x0  
    float ytl=341-(x_center-width/2)/120*512;//y0 
    
    
    
    float xbr=256-(y_center+ width/2)/80*512;//x3
    float ybr=341-(x_center+height/2)/120*512;//y3
    
    
    float rect_width=xbr-xtl;
    float rect_height=ybr-ytl;
    
     
    float x1=xtl+rect_width/2;
    float y1=ytl;
    
    
    float x2=xtl;
    float y2=ytl+rect_height/2;
      
  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =100;
  disp_meta->line_params[disp_meta->num_lines].y2 =0;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  
  disp_meta->line_params[disp_meta->num_lines].x1 =100;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =100;
  disp_meta->line_params[disp_meta->num_lines].y2 =100;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  

  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =0;
  disp_meta->line_params[disp_meta->num_lines].x2 =0;
  disp_meta->line_params[disp_meta->num_lines].y2 =100;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;
  
  disp_meta->line_params[disp_meta->num_lines].x1 =0;
  disp_meta->line_params[disp_meta->num_lines].y1 =100;
  disp_meta->line_params[disp_meta->num_lines].x2 =100;
  disp_meta->line_params[disp_meta->num_lines].y2 =100;
  disp_meta->line_params[disp_meta->num_lines].line_width = 4;
  disp_meta->line_params[disp_meta->num_lines].line_color.red = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.green = 0.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.blue = 1.0;
  disp_meta->line_params[disp_meta->num_lines].line_color.alpha = 0.5;
  disp_meta->num_lines=disp_meta->num_lines+1;

     }
  }    
  
}

if(disp_meta)
nvds_add_display_meta_to_frame (frame_meta, disp_meta);
}
gst_buffer_unmap (buf, &in_map_info);
return GST_PAD_PROBE_OK;
}

Please provide complete information as applicable to your setup.

Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hardware Platform (Jetson / GPU)
Rtx3060
• DeepStream Version
Deepstream6.2
• TensorRT Version
Tensorrt 8.5.2
• NVIDIA GPU Driver Version (valid for GPU only)
525.85.12
• Issue Type( questions, new requirements, bugs)
Problems with using NvDsDisplayMeta.
**• How to reproduce the issue ?
It is rendered in a way similar to the drawing of lines for human key detection(deepstream_tao_apps/apps/tao_others/deepstream-bodypose2d-app at master · NVIDIA-AI-IOT/deepstream_tao_apps · GitHub)。
**• Requirement details。
The engineering that imitates the key points of the human body, the meta data of the rotating box is customized, the rendering part of the model inference, and the memory leakage problem occurs with the use of NvDsDisplayMeta.

Could you attach more log info with GST_DEBUG=3?

There are no mistakes when I draw 3 lines.

There is a maximum limit of num_lines,have you done any special process? You can refer to below:
https://github.com/NVIDIA-AI-IOT/deepstream_tao_apps/blob/master/apps/tao_others/deepstream-bodypose2d-app/deepstream_bodypose2d_app.cpp#L237

That’s it. Thank you. Problem solved。

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