cbusch
cbusch

Reputation: 325

Swift's Vision framework not recognizing Japanese characters

I would like to read Japanese characters from a scanned image using swift's Vision framework. However, when I attempt to set the recognition language of VNRecognizeTextRequest to Japanese using

request.recognitionLanguages = ["ja", "en"]

the output of my program becomes nonsensical roman letters. For each image of japanese text there is unexpected recognized text output. However, when set to other languages such as Chinese or German the text output is as expected. What could be causing the unexpected output seemingly peculiar to Japanese?

I am building from the github project here.

Upvotes: 4

Views: 1239

Answers (2)

CH Wing
CH Wing

Reputation: 1201

VisionKit has been support more language after mac update to macos Ventura.

need rebuild app using xcode 14

VNRecognizeTextRequest().supportedRecognitionLanguages()

["en-US", "fr-FR", "it-IT", "de-DE", "es-ES", "pt-BR", "zh-Hans", "zh-Hant", "yue-Hans", "yue-Hant", "ko-KR", "ja-JP", "ru-RU", "uk-UA"]

Upvotes: 0

Rob
Rob

Reputation: 438112

As they said in WWDC 2019 video, Text Recognition in Vision Framework:

First, a prerequisite, you need to check the languages that are supported by language-based correction...

Look at supportedRecognitionLanguages for VNRecognizeTextRequestRevision2 for “accurate” recognition, and it would appear that the supported languages are:

["en-US", "fr-FR", "it-IT", "de-DE", "es-ES", "pt-BR", "zh-Hans", "zh-Hant"]

If you use “fast” recognition, the list is shorter:

["en-US", "fr-FR", "it-IT", "de-DE", "es-ES", "pt-BR"]

And if you fall back to VNRecognizeTextRequestRevision1, it is even shorter (lol):

["en-US"]

It would appear that Japanese is not a supported language at this point.

Upvotes: 4

Related Questions