March 2019
Intermediate to advanced
532 pages
13h 2m
English
OpenCV provides more functions in connection with text drawing. It should be noted that these functions are not for drawing text, but they can be used to complement the aforementioned cv2.putText() function, and they are commented as follows. The first function we are going to see is cv2.getFontScaleFromHeight(). The signature for this function is as follows:
retval = cv2.getFontScaleFromHeight(fontFace, pixelHeight, thickness=1)
This function returns the font scale (fontScale), which is a parameter to use in the cv2.putText() function, to achieve the provided height (in pixels) and taking into account both the font type (fontFace) and thickness.
The second function is cv2.getTextSize():
retval, baseLine = cv2.getTextSize(text, ...