title: How to resize text for cv2.putText according to the image size in OpenCV, Python?
body: <pre class="lang-py prettyprint-override"><code>fontScale = 1
  fontThickness = 1
  
  # make sure font thickness is an integer, if not, the OpenCV functions that use this may crash
  fontThickness = int(fontThickness)
  
  upperLeftTextOriginX = int(imageWidth * 0.05)
  upperLeftTextOriginY = int(imageHeight * 0.05)
  
  textSize, baseline = cv2.getTextSize(resultText, fontFace, fontScale, fontThickness)
  textSizeWidth, textSizeHeight = textSize
  
  # calculate the lower left origin of the text area based on the text area center, width, and height
  lowerLeftTextOriginX = upperLeftTextOriginX
  lowerLeftTextOriginY = upperLeftTextOriginY + textSizeHeight
  
  # write the text on the image
  cv2.putText(openCVImage, resultText, (lowerLeftTextOriginX, lowerLeftTextOriginY), fontFace, fontScale, Color,
              fontThickness)
  </code></pre>
  <p>It seems <code>fontScale</code> does not scale text according to the image width and height because the text is almost in the same size for different sized images. So how can I resize the text according to the image size so that all the text could fit in the image?</p>