How to pass an array to downstream element with python?

Please provide complete information as applicable to your setup.

• Hardware Platform : dGPU
• DeepStream Version: 7.0
• TensorRT Version: 8.6.1.6
**• NVIDIA GPU Driver Version: 555.58.02 **
• Issue Type: Question

For example, each object from pgie have additional data (for example an array like[1,2,3,4]) and this array is needed for preprocessing in sgie. How can i send this data to downstream elements?

  1. could you share the scenario? how are the additional data used n sgie?
  2. what is the whole media pipeline? is it “…->pgie->nvdspreprocess->sgie->…”? you can add usermeta to objectmeta by nvds_add_user_meta_to_obj. please refer to this sample. then in nvdspreprocess, fetch and process these usermeta. please refer to this sample.

So i have a pipeline that look like this

pgie(face detect with landmark)-> nvdspreprocess(use the landmark to align face) -> sgie(face embedding)

Currently i got face landmark after pgie post processing but i dont know how to send it to nvdspreprocess.

  1. Thanks for the sharing! please refer to the two samples in my last comment. you can use nvds_add_user_meta_to_obj to add custom user data for every object. then in nvdspreprocess, you get the custom user data from the obj_user_meta_list.
  2. will you generate new face or new landmark in nvdspreprocess? what the results of “use the landmark to align face”?

I actually solved this by allocate an array with mask_params as i have no intention of doing any instance segmentation task later.

# Add mask data at pgie src pad
    def modify_mask_data(obj_meta, landmark_data):
        # Access the mask_params from obj_meta
        maskparams = obj_meta.mask_params
        maskparams.height = 1
        maskparams.width = len(landmark_data)
        # Create a NumPy array to hold the mask data (e.g., a binary mask)
        mask_array = landmark_data  

        # Assuming alloc_mask_array allocates memory for the mask array
        mask_array_ptr = maskparams.alloc_mask_array()

        if isinstance(mask_array_ptr, np.ndarray):

            mask_array_ptr[:] = mask_array  # Copy the mask data to the allocated array
            #print("Updated mask array:", maskparams.get_mask_array())
        else:
            print("Error")

# Acess data in nvdspreprocess: 
  float* mask_data = obj_meta->mask_params.data;
  unsigned int mask_size = obj_meta->mask_params.size / sizeof(float); 
  for (unsigned int i = 0; i < mask_size; ++i) {
      float value = mask_data[i];
      printf("Landmark value: %f\n",value);
      // Process the mask value as needed
  }

Maybe i will have to create custom user data but this works for now. Thanks for your support, absolutely love it.

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