Mask_param data interpret

Continuing the discussion from Interpret mask_params data from PeopleSegNetV2:

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)

about the pic,I have 2 questions:
1)for the deepstream pipline like streammux!nvinfer(seg model)!nvtracker!nvosd!,if I add a pad in the osd src,the channel params in the pic should set to 3? or 1?
2)when i use the function nvds_mask_utils_resize_to_binary_argb32, the params argb_32,interpolation,stream should set to what?any suggestions?

thank you so much,the answer is important for me !looking forward!

What do you mean add a pad in the osd src?

Please refer to our source code sources\includes\nvds_mask_utils.h.

 * @param  argb_32 [IN] The pixel value in dst when src pixel > threshold
 * @param  interpolation [IN] The NPP interpolation method to use
 *         Enumeration copied below:
 *         NPPI_INTER_NN =1, Nearest neighbor filtering.
 *         NPPI_INTER_LINEAR Linear interpolation.
 *         NPPI_INTER_CUBIC Cubic interpolation.
 *         NPPI_INTER_CUBIC2P_BSPLINE Two-parameter cubic filter (B=1, C=0)
 *         NPPI_INTER_CUBIC2P_CATMULLROM Two-parameter cubic filter (B=0, C=1/2)
 *         NPPI_INTER_CUBIC2P_B05C03 Two-parameter cubic filter (B=1/2, C=3/10)
 *         NPPI_INTER_SUPER Super sampling.
 *         NPPI_INTER_LANCZOS Lanczos filtering.
 *         NPPI_INTER_LANCZOS3_ADVANCED Generic Lanczos filtering with order 3.
 *         NPPI_SMOOTH_EDGE Smooth edge filtering.
 * @param  stream [IN] The cuda-stream to use for scaling operation on GPU

so glad to receive your reply,thanks!
What do you mean add a pad in the osd src ?
sorry,it’s add a probe in osd src pad.
Please refer to our source code sources\includes\nvds_mask_utils.h .
In fact, I have carefully read these parameter definitions, but I am not very familiar with them, especially the stream parameter. I really don’t know how to get it. I tried to set it to NULL, but there was an segmentation error when the program runing.

About the channel, you can get the num_planes from the nvbufsurface.

The stream means cudaStream_t.

We recommend that you learn some cuda and NvbufSurface basics before customizing your own code, otherwise there will be some exceptions in your own code.

1 Like

hi,listen to youradvice,I learn some easy function about cuda,now i have two questions:
Please check if this process is correct,

  1. Memory request
    cudaMalloc(&src_data, mask_width * mask_height * sizeof(float));
    cudaMalloc(&dst_data, stream_width * stream_height * sizeof(uint32_t));
    Perform memory requests for both the original and target mask data separately;
  2. Create stream variables
    cudaStream_t stream;
    cudaStreamCreate(&stream);
  3. Wait for stream processing
    cudaStreamSynchronize(stream);
  4. Release memory
    cudaFree(src_data);
    cudaStreamDestroy(stream);

Two questions:
What are the loopholes in the above process?
2. Is the size of the memory request for src mask data calculated using the size in mask_params or through mask_weight * mask_height * sizeof (float)?

You can get that from the float *data; and unsigned int size; form the NvOSD_MaskParams.

1 Like

anotherquestion please:What are the loopholes in the above process?

Your basic process is correct. You need to pay attention to whether the memory is on the host or on the device.

1 Like

thanks to you professional reply , i use the above step and acquire the data like this


about the introduction of the nvds_mask_utils_resize_to_binary_argb32 function said “ARGB32 For resized pixels > threshold, transparency is set to 50% and other pixels are set to 100% transparent; RGB = 0 for all pixels”
two questions:

  1. Why is the transparency of the data I receive equal to others (not 50% and 100%)? What does this mean?
  2. I set the nvds_mask_utils_resize_to_binary_argb32 param argb32_px equal to 0xFFFFFFFF,why the r,g,b isn’t equal to 255?
  3. How can I use the parsed data to convert them into binary masks?

by the way the threshold that i set is equal to 0.5.

argb32_px is the pixel value in dst when src pixel > threshold.
You can check the data from the dst.

1 Like

thank you very much for your reply!

  1. its uint32_t argb32_px = 0xFFFFFFFF is right?
  2. cudaMalloc(&dst_data, stream_width * stream_height * sizeof(uint32_t));its the sizes stream_width * stream_height * sizeof(uint32_t) is right? Is it means a pic have 3 channels and the pixel of each channel can get in uint32_t?

This means that the pixel is opaque white colour.

It means a pic have 4 channels: argb.

everything work well but only one question: the dst uint32_t data is not equal to my setting value, 1. I set the nvds_mask_utils_resize_to_binary_argb32 param argb32_px equal to 0xFFFFFFFF,why the r,g,b isn’t equal to 255?

 * @param  argb_32 [IN] The pixel value in dst when src pixel > threshold

You need to make sure if it meets the above condition.

If the pixel I set is 0xFFFFFFFF, what happens when src pixel>threshold is not met?

Let’s not debug this non-open source code for a while.
Could you describe in more detail the problems you encountered in our demo and the final results you want?

I just want to get the right segmentation result and covert it to the binary value

Our latest nvsegvisual version supports this scenario. You can set the alpha and original-background parameter to meet your needs. Please refer to our demo tao_segmentation.

I tried your method to add the nvsegvisual element , but it not work , my model is yolo-seg, it don’t have the NvDsInferSegmentationMeta data,it’s seg results contained in the obj_meta->mask_params,any method can i decrease the running time of the nvds_mask_utils_resize_to_binary_argb32 ?

OK, now I understand. The yolo-seg is an instance segmetation model, so we cannot use nvsegvisual plugin to draw the mask. Can you attach a picture to illustrate the result you want? We can support the instance segvisual model too. You can refer to our demo mask2former.