How does maintain-aspect-ratio works in nvinfer?

When using Nvinfer in secondary classifier mode to maintain-aspect-ratio, does it create black bars at the edges or it increases the bbox roi to match the aspect ratio ?

Hi,

YES. The image is padding with black color.
You can find the detail implementation in this file:
/opt/nvidia/deepstream/deepstream-5.0/sources/gst-plugins/gst-nvinfer/gstnvinfer.cpp

  if (nvinfer->maintain_aspect_ratio) {
    /* Calculate the destination width and height required to maintain
     * the aspect ratio. */
    double hdest = dest_frame->width * src_height / (double) src_width;
    double wdest = dest_frame->height * src_width / (double) src_height;
    int pixel_size;
    cudaError_t cudaReturn;
    ...

Thanks.

1 Like