Printing text on images

OpenCV contains a very easy-to-use function named putText to draw, or print, text on images. This function requires an image as the input/output parameter, which means the source image itself will be updated. So, be sure to make a copy of your original image in memory before calling this function. You also need to provide this function with an origin point, which is simply the point where the text will be printed. The font of the text must be one of the entries in the HersheyFonts enum, which can take one (or a combination) of the following values:

  • FONT_HERSHEY_SIMPLEX
  • FONT_HERSHEY_PLAIN
  • FONT_HERSHEY_DUPLEX
  • FONT_HERSHEY_COMPLEX
  • FONT_HERSHEY_TRIPLEX
  • FONT_HERSHEY_COMPLEX_SMALL
  • FONT_HERSHEY_SCRIPT_SIMPLEX
  • FONT_HERSHEY_SCRIPT_COMPLEX ...

Get Hands-On Algorithms for Computer Vision now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.