Using CUDA font to input Chinese characters with garbled characters

version:
Orin NX Developer Kit
Jetpack 5.1.1
L4T 35.3.1

example from jetson

Hi ,every one ,Thank you very much for your project 。
When using CUDA font to input English, there is no problem, but entering Chinese will result in garbled characters? How should I fix this issue?

We look forward to your reply

input str
image
output result

Hi,

You can set the font below:

Please modify it to the one that supports your language.

Thanks.

hi, Thank you for your reply. Is it to modify the TTF file? I modified it to support Chinese TTF, but it still cannot output

test cmd

./imagenet images/orange_0.jpg  out.jpg

diff

draw text
image

result


There are no garbled characters on the image, but Chinese characters cannot be output

Hi,

Does the hhh use the new font to display?
If yes, the font can load currently but the text cannot be parsed.

Thanks.

Thank you for your reply. hhh can be displayed normally, but the 测试 图片 cannot be displayed. How can I modify it to display Chinese? This font supports Chinese. Thank you

Hi,

Is the hhh use the font you add?
This helps us to narrow down the issue.

Thanks.

Yes, I added it using my font. Do I need to provide a TTF file?

Hi,

Yes, it will help.
Could you also provide a reproducible source so we can check how to modify it to work?

Thanks.

Hi,
diff from jetson-utils

git diff
diff --git a/cuda/cudaFont.cu b/cuda/cudaFont.cu
index b4d8ada..13d2230 100644
--- a/cuda/cudaFont.cu
+++ b/cuda/cudaFont.cu
@@ -127,9 +127,8 @@ cudaFont* cudaFont::Create( float size )
        // default fonts        
        std::vector<std::string> fonts;
        
-       fonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf");
-       fonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
 
+       fonts.push_back("/home/ainnovation/jetson-inference/chinese.ttf");
        return Create(fonts, size);
 }

diff from jetson-inference

git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abad4c32..1d77865d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,7 +103,7 @@ else()
 endif()
        
 # check for VPI (TODO: VPI 1.0 support for JetPack 4.x)
-find_package(VPI 2.0)
+#find_package(VPI 2.1) 
 
 if( NOT VPI_FOUND )
        message("-- didn't find VPI on system, disabling VPI")
diff --git a/examples/imagenet/imagenet.cpp b/examples/imagenet/imagenet.cpp
index d8783c21..7e757a83 100644
--- a/examples/imagenet/imagenet.cpp
+++ b/examples/imagenet/imagenet.cpp
@@ -165,7 +165,7 @@ int main( int argc, char** argv )
                        LogVerbose("imagenet:  %2.5f%% class #%i (%s)\n", confidence, classID, classLabel);     
 
                        char str[256];
-                       sprintf(str, "%05.2f%% %s", confidence, classLabel);
+                       sprintf(str, "测试 图片 hhh %05.2f%% %s", confidence, classLabel);
                        font->OverlayText(image, input->GetWidth(), input->GetHeight(),
                                                   str, 5, 5 + n * (font->GetSize() + 5), 
                                                   make_float4(255,255,255,255), make_float4(0,0,0,100));
diff --git a/utils b/utils
--- a/utils
+++ b/utils

because website not support ttf format , chang “chinese.txt” to “chinesse.ttf” please
chinese.txt (2.6 MB)

Hi,

Thanks for the sharing.
Confirmed that we can reproduce the same issue in our environment.

Will let you know once we find a solution.

Thanks.

HI
Okay, looking forward to your solution .

Hi,

Jetson-utils use char to map text to image.
So it won’t be able to support the utf-8 characters.

Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.