This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
def get_font_point_and_scale(text, x, y, h, w, thickness, font): | |
(text_width, text_height) = cv2.getTextSize(text, font, 1.0, thickness)[0] | |
scalex = w/text_width | |
scaley = h/text_height | |
scale = min(scalex, scaley) | |
marginx = 0 if scale == scalex else int(w *(scalex-scale)/scalex*0.5) | |
marginy = 0 if scale == scaley else int(h *(scaley-scale)/scaley*0.5) |
OlderNewer