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 ?

1 Like


YES. The image is padding with black color.
You can find the detail implementation in this file:

  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;


1 Like