OpenCV in Java: how can I output all kind of symbols? (Chinese, Japanese, Accents, etc…)

I’m new to OpenCv and I’m doing a project in Android Studio using Object Detection. The idea behind my project is to translate the name of a selected object, in a language that the user can choose. My problem is that when I do
Imgproc.putText(frame, testo, box.tl(), Core.FONT_ITALIC, 2, new Scalar(255, 255, 255), 3);
(where “testo” is the translated name) in a language with specific symbols (like Chinese or Japanese, or simply with accents) it just gives me “???” as output. I saw that putText only works with ASCII characters and I also saw that there is a module called FreeType, but I didn’t get if is just usable in C++ or also in Java. Does anyone know what can I do? Or if maybe there are other modules that I can use? Thanks a lot in advance!

yea, that’s the one to use.
unfortunately, as of today, there are no java wrappers for it .

if you feel like experimenting:


on the other hand, how many unique strings do you expect ? maybe it's far easier to overlay prerendered images ?
1 Like

I’m just putting a word, in the exemple:
Imgproc.putText(frame, text, box.tl(), Core.FONT_ITALIC, 2, new Scalar(255, 255, 255), 3);
text is just one word, but it can be in many different languages, it depends on which language the user choose, so that’s why I have to handle all the languages…
What do you mean by “overlay pretendere images”? I can do it on the camera view?
thanks a lot for your help!

use gimp or such to render your chinese text into a small image, then:

Mat small_img_with_txt = imread("chinese_txt.png");
Rect dst(13,13, small_img_with_txt.cols, small_img_with_txt.rows);

small_img_with_txt.copyTo(frame.submat(dst));
1 Like

Thank you so much!! That was very helpful!