code: def _letterbox_image(img, w_in, h_in):
      """To get the image in boxed format."""
      imh, imw, imc = img.shape
      if (w_in / imw) < (h_in / imh):
          new_w = w_in
          new_h = imh * w_in // imw
      else:
          new_h = h_in
          new_w = imw * h_in // imh
      dim = (new_w, new_h)
      # Default interpolation method is INTER_LINEAR
      # Other methods are INTER_AREA, INTER_NEAREST, INTER_CUBIC and INTER_LANCZOS4
      # For more information see:
      # https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#resize
      resized = cv2.resize(
          src=img, dsize=dim, interpolation=cv2.INTER_CUBIC
      )
      resized = convert_image(resized)
      boxed = np.full((imc, h_in, w_in), 0.5, dtype=float)
      _, resizedh, resizedw = resized.shape
      boxed[
          :,
          int((h_in - new_h) / 2) : int((h_in - new_h) / 2) + resizedh,
          int((w_in - new_w) / 2) : int((w_in - new_w) / 2) + resizedw,
      ] = resized
      return boxed
  
file_path: tvm/python/tvm/relay/testing/darknet.py
imports: from __future__ import division
  from cffi import FFI
  import numpy
  import cv2
label_desc: Use image node_id 3 for calling a global function with example usage: _letterbox_image(img, w_in, h_in) and returns: boxed