Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How can I add a font on OpenCV library in python?

$
0
0

I have a very specific question to ask regarding fonts on OpenCV.

As well known, the fonts are predefined, and if you want to use fonts that are not in the list, you need the help of PIL(Pillow).

Now my problem is that Pillow allows to do some operations with a font, but for example it doesn't allow to calculate its height which I need.

So I have a doubt, if the OpenCV library has a list of fonts available it is possible to add one to the list.

To explain myself better, I think the Hershey fonts it uses are somewhere, I don't know if in a file or elsewhere.So the possibility of modifying the library and adding one doesn't seem so remote to me (Maybe I'm wrong).

I know the question is very specific and maybe not possible to answer, but I would appreciate any kind of help or critique of my question that could point me in the right direction.

Plus I want to ask as a last question in case there is no answer to the first.There is a font management library fully compatible with this syntax on OpenCV that allows me to replace fontFace with another font:

cv2.putText(img=white_back, text=text, org=(bl[0], bl[1] - 10), fontFace="FONT_NOT_HERSHEY", fontScale=font_scale, color=(0, 0, 0), thickness=thickness, lineType=cv2.LINE_AA)

Thanks in advance for any help


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>