Skip to Content
Mastering OpenCV 4 with Python
book

Mastering OpenCV 4 with Python

by Alberto Fernández Villán
March 2019
Intermediate to advanced
532 pages
13h 2m
English
Packt Publishing
Content preview from Mastering OpenCV 4 with Python

More functions related to text

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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

OpenCV 4 with Python Blueprints - Second Edition

OpenCV 4 with Python Blueprints - Second Edition

Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler
Learning OpenCV 3

Learning OpenCV 3

Adrian Kaehler, Gary Bradski
Machine Learning for OpenCV 4 - Second Edition

Machine Learning for OpenCV 4 - Second Edition

Aditya Sharma, Michael Beyeler (USD), Vishwesh Ravi Shrimali, Michael Beyeler

Publisher Resources

ISBN: 9781789344912Supplemental Content