Code Yarns ‍👨‍💻

Fonts in OpenCV

(First posted on: 2015-03-11 12:23:33+00:00)

 
 

OpenCV can be used to render text on an image buffer using the putText function. Several simple fonts are available in OpenCV which can be used to write text.

The available fonts can be seen defined in modules/core/include/opencv2/core/core.hpp header file:

enum
{
    FONT_HERSHEY_SIMPLEX = 0,
    FONT_HERSHEY_PLAIN = 1,
    FONT_HERSHEY_DUPLEX = 2,
    FONT_HERSHEY_COMPLEX = 3,
    FONT_HERSHEY_TRIPLEX = 4,
    FONT_HERSHEY_COMPLEX_SMALL = 5,
    FONT_HERSHEY_SCRIPT_SIMPLEX = 6,
    FONT_HERSHEY_SCRIPT_COMPLEX = 7,
    FONT_ITALIC = 16
};

FONT_ITALIC is not a font, but can be combined with the other fonts to get italic text.

Tried with: OpenCV 2.4.9 and Ubuntu 14.04