How to acess nvinfer's padding/scaling data with maintain-aspect-ratio=1

Hardware Platform: dGPU
**• DeepStream Version: 7.0 **
• TensorRT Version: 8.6.1
• NVIDIA GPU Driver Version: 550
• Issue Type: question

For example if i set maintain-aspect-ratio=1 and symmetric-padding=1, the image could look like this. But is there any way to use Deepstream API to get how much i pad on each side and how much i scale down the image.

Can you briefly introduce your pipeline? From the previous topic, it seems that you are doing some custom nvdspreprocess work. This seems to be irrelevant to this topic.

For symmetric padding, please refer to the following code snippets of get_converted_buffer in /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvinfer/gstnvinfer.cpp

/* Symmetric Padding. */
      offset_left = (dest_frame->width - dest_width) / 2;
      offset_right = dest_frame->width - dest_width - offset_left;

      cudaReturn =
          cudaMemset2DAsync ((uint8_t *) destCudaPtr,
          dest_frame->planeParams.pitch[0], 0,
          pixel_size * offset_left, dest_frame->height, nvinfer->convertStream);
      if (cudaReturn != cudaSuccess) {
        GST_ERROR_OBJECT (nvinfer,
            "cudaMemset2DAsync failed with error %s while converting buffer",
            cudaGetErrorName (cudaReturn));
        return GST_FLOW_ERROR;
      }

I was trying to do some image warping with nvdspreprocess therefore i need to know how much image is padded. It seems that i can caculate the padding base on this code.

If you are using nvdspreprocess, then nvinfer will directly process the tensor generated by nvdspreprocess(it is called NVDS_PREPROCESS_BATCH_META in deepstream) without aligning the image.

Refer to the block diagram of nvinfer/nvdspreprocess below.

If you want to achieve image warping in nvdspreprocess, I think you can modify CustomTransformation/CustomAsyncTransformation in /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvdspreprocess/nvdspreprocess_lib/nvdspreprocess_lib.cpp

Yes i have been able to warp my own image by modifying nvdspreprocess and push it to nvinfer downstream. It is just i need to caculate warping diffrently when padding is involved since i set padding on nvdspreprocess. Base on the source code you provide, i guess i can work on that to recaculate my warping. Thanks for helping, love it.