Null value for

Hardware Platform: Jetson nano
DeepStream Version: 6.0
JetPack Version 4.6.1

I want to get access to the frames in deepstream-app to crop ROI images and save the images to a specific path.

I have implemented the following to the gie_primary_processing_done_buf_prob probe:

gint frame_number = 0;
#define PGIE_CLASS_ID_VEHICLE 0
#define PGIE_CLASS_ID_PERSON 2

static GstPadProbeReturn
gie_primary_processing_done_buf_prob (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *) info->data;
  guint num_rects = 0;
  NvDsObjectMeta *obj_meta = NULL;
  guint vehicle_count = 0;
  guint person_count = 0;
  NvDsMetaList *l_frame = NULL;
  NvDsMetaList *l_obj = NULL;
  NvDsDisplayMeta *display_meta = NULL;
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
  int current_device = -1;
  cudaGetDevice(&current_device);
  struct cudaDeviceProp prop;
  cudaGetDeviceProperties(&prop, current_device);
    AppCtx *appCtx = (AppCtx *) u_data;

  if (!batch_meta) {
    NVGSTDS_WARN_MSG_V ("Batch meta not found for buffer %p", buf);
    return GST_PAD_PROBE_OK;
  }
  gchar bbox_file[1024] = { 0 };
  FILE *bbox_params_dump_file = NULL;

  if (!appCtx->config.bbox_dir_path)
    return;



  for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
    NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
    guint num_rects = 0;
    int offset = 0;
    for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
        l_obj = l_obj->next) {
      NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
      
       obj_meta = (NvDsObjectMeta *) (l_obj->data);
       printf("\n");
       printf("class_id: %d\n", obj_meta->class_id);
       printf("\n");

        if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
          vehicle_count++;
          num_rects++;
        }
        if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
          person_count++;
          num_rects++;
        }
        
      char fileNameString[FILE_NAME_SIZE];
      const char *osd_string = "OSD";
      int obj_res_width = (int) obj_meta->rect_params.width;
      int obj_res_height = (int) obj_meta->rect_params.height;
      if(prop.integrated) {
        obj_res_width = GST_ROUND_DOWN_2(obj_res_width);
        obj_res_height = GST_ROUND_DOWN_2(obj_res_height);
      }    

      snprintf (fileNameString, FILE_NAME_SIZE, "%s_%d_%d_%d_%s_%dx%d.jpg",
          osd_string, frame_number, frame_meta->source_id, num_rects,
          obj_meta->obj_label, obj_res_width, obj_res_height);
      
      
      if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE || obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
        NvDsUserMetaList *usrMetaList = obj_meta->obj_user_meta_list;
        FILE *file;
        // printf("%s\n","reached here!");
        printf("Person Count:%d\n",person_count);
        
        if (usrMetaList == NULL) {
          printf("%s\n","Null here!");
        }
        
        while (usrMetaList != NULL) {
          
          printf("%s\n","Not Null!");

          NvDsUserMeta *usrMetaData = (NvDsUserMeta *) usrMetaList->data;
          if (usrMetaData->base_meta.meta_type == NVDS_CROP_IMAGE_META) {
            NvDsObjEncOutParams *enc_jpeg_image =
                (NvDsObjEncOutParams *) usrMetaData->user_meta_data;
            /* Write to File */
            file = fopen (fileNameString, "wb");
            fwrite (enc_jpeg_image->outBuffer, sizeof (uint8_t),
                enc_jpeg_image->outLen, file);
            fclose (file);
            usrMetaList = NULL;
          } else {
            usrMetaList = usrMetaList->next;
          }
        }
      }

      

      float left = obj->rect_params.left;
      float top = obj->rect_params.top;
      float right = left + obj->rect_params.width;
      float bottom = top + obj->rect_params.height;
      float confidence = obj->confidence;

      printf("Label: %s\n", obj->obj_label);
      printf("left: %f\n",left);
      printf("top: %f\n",top);
      printf("right: %f\n",right);
      printf("bottom: %f\n",bottom);
      printf("\n");
          
      }
        
  }
  frame_number++;
  return GST_PAD_PROBE_OK;
}

I am getting a null value for usrMetaList. What I have done wrong in the code?

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

1.run “export GST_DEBUG_DUMP_DOT_DIR=.” before deepstream-app command. Check the position of preprocess at pipeline

NVDS_CROP_IMAGE_META create by nvds_obj_enc_process,
meta type created by preprocess is NVDS_PREPROCESS_BATCH_META

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