Frames gets corrupted when extracting it from buffer in the appsink

I am running Deepstream 5.1 on Dell G5 15 the GPU is GTX 1650ti the OS is Ubuntu 18.04.5LTS tensorrt version GPU Driver 460.39 CUDA version 11.2

I have a pipeline that is like this:


I read the buffer in the appsink and extract the meta data and frames batch to do further processing on them this is the code I read the images and the metadata with.

for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
         l_frame = l_frame->next)
      std::vector<cv::Rect> persons;

      NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);

      g_frame_idx = frame_meta->frame_num;

      NvBufSurfaceMap(surface, -1, -1, NVBUF_MAP_READ_WRITE);

      NvBufSurfaceSyncForCpu(surface, 0, 0);

      cv::Mat in_mat = cv::Mat(surface->surfaceList[frame_meta->batch_id].planeParams.height[0],
                               surface->surfaceList[frame_meta->batch_id].planeParams.width[0], CV_8UC4,

      std::cout<<"Pad Index: "<<frame_meta->pad_index<<std::endl;
      std::cout<<"Batch ID: "<<frame_meta->batch_id<<std::endl;

      g_imagesBatch[frame_meta->pad_index] = in_mat;


      pts = frame_meta->buf_pts;
      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->class_id == PGIE_CLASS_ID_PERSON)
          cv::Rect person(obj_meta->tracker_bbox_info.org_bbox_coords.left, obj_meta->, obj_meta->tracker_bbox_info.org_bbox_coords.width, obj_meta->tracker_bbox_info.org_bbox_coords.height);
      g_personsBatch[frame_meta->pad_index] = persons;

where g_imagesBatch is a global std::vector<cv::Mat> and g_personsBatch is a global std::vector<std::vector<cv::Rect>>

I lock a mutex before writing to the g_imagesBatch and unlock it after finishing.

The problem is some frames in say source number 0 say 2 frames in 3000 frames comes mixed with other frames from source number 1 and I don’t know why is this happening please provide some help if you know a solution.

How many sources do you have?

What do you mean by this description? How did you know source 0 frames are mixed with source 1 frames?

Now I have 2 sources I mean for example the frame of source 0 have a part from the frame of source 1. This is a picture of the corrupted frame of source 0.

1 Like

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.

Can you provide a complete code and configuration which we can reproduce the problem in our side?

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