Search code examples
imageopencvtruetype

OpenCV: How to use other font than HERSHEY with cvPutText (like Arial)


I want to write to an image a formatted text. OpenCV offers only a limited set of default fonts. Is it possible to use others? For example to read them from the *.ttf file (in Ubuntu)?


Solution

  • It's possible to use other fonts but you need to link the Qt library to OpenCV and use the cvAddText function with a cvFontQt

    http://docs.opencv.org/modules/highgui/doc/qt_new_functions.html#addtext

    http://docs.opencv.org/modules/highgui/doc/qt_new_functions.html#fontqt

    There are other solutions you might try, with more or less the same performance as OpenCV. For instance, you can use CAIRO to write fonts into the image.