0

Opencv cv::putText doesn't seem to support the chinese or japanese text (unicode string) to be overlayed on the image.

Is any workaround available?

cv::putText(img, //target image
            "你好世界", //text
            cv::Point(10, img.rows / 2), //top-left position
            cv::FONT_HERSHEY_DUPLEX,
            1.0,
            CV_RGB(118, 185, 0), //font color
            2);

However, the text written on the image is: "??????"

JeJo
  • 30,635
  • 6
  • 49
  • 88
Joe
  • 1
  • The Hershey font has a very small number of glyphs. You can install your own font. https://stackoverflow.com/questions/37191008/load-truetype-font-to-opencv – Tim Roberts Jul 02 '23 at 19:20

1 Answers1

-1

Non-English text overlaying using opencv C++ cv::putText Android native

Workaround:

  1. https://github.com/castle-engine/android-freetype : Download and build freetype library for Android.
  2. Build https://github.com/sibojia/cv-uni-text with freetype for Android.
  3. For overlaying text on image, Use uniText.PutText(img, "你好世界", p, color, false); (instead of cv::putTest)
karel
  • 5,489
  • 46
  • 45
  • 50
Joe
  • 1