📜  相对文本大小 put text cv2 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:57.098000             🧑  作者: Mango

代码示例1
def get_optimal_font_scale(text, width):
    for scale in reversed(range(0, 60, 1)):
      textSize = cv.getTextSize(text, fontFace=cv.FONT_HERSHEY_DUPLEX, fontScale=scale/10, thickness=1)
      new_width = textSize[0][0]
      #print(new_width)
      if (new_width <= width):
          return scale/10
    return 1