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

**URL:** <https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112>\
**Category:** Android/Java\
**Tags:** imgproc, contrib, freetype\
**Created:** [July 1, 2021, 12:30pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112 "2021-07-01T12:30:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArieleSgheiza](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/arielesgheiza/32/2550_2.png) [@ArieleSgheiza](https://forum.opencv.org/u/ArieleSgheiza)\
**Post date:** [July 1, 2021, 12:30pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112/1 "2021-07-01T12:30:54Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 1, 2021, 12:39pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112/2 "2021-07-01T12:39:59Z")

</div>

> [@ArieleSgheiza](#):
>
> I also saw that there is a module called FreeType,

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

if you feel like experimenting:

- download [GitHub - opencv/opencv\_contrib: Repository for OpenCV's extra modules](https://github.com/opencv/opencv_contrib)
- add it to your build script
- build the resp. dependancies for your platform (freetype, harfbuzz)
- add JAVA [at the end of this line](https://github.com/opencv/opencv_contrib/blob/master/modules/freetype/CMakeLists.txt#L24) , between `python` and the `)`
- rebuild the opencv android sdk

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

---

<div class="post-metadata">

**Author:** ![ArieleSgheiza](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/arielesgheiza/32/2550_2.png) [@ArieleSgheiza](https://forum.opencv.org/u/ArieleSgheiza)\
**Post date:** [July 1, 2021, 1:24pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112/3 "2021-07-01T13:24:01Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 1, 2021, 1:34pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112/4 "2021-07-01T13:34:35Z")

</div>

> [@ArieleSgheiza](#):
>
> What do you mean by “overlay pretendere images”?

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

```auto
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));

```

---

<div class="post-metadata">

**Author:** ![ArieleSgheiza](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/arielesgheiza/32/2550_2.png) [@ArieleSgheiza](https://forum.opencv.org/u/ArieleSgheiza)\
**Post date:** [July 1, 2021, 1:59pm UTC](https://forum.opencv.org/t/opencv-in-java-how-can-i-output-all-kind-of-symbols-chinese-japanese-accents-etc/4112/5 "2021-07-01T13:59:24Z")

</div>

Thank you so much!! That was very helpful!
