Not work on Chinese language
kevinnerd opened this issue · comments
Hi, it seems this tool can't work properly on image with Chinese language, does it only work with English ?
Will Chinese be supported later versions ?
Modify line 52 of main.swift
to have:
request.recognitionLanguages = ["zh", "en"]
Then it will work.
Hi Kevin,
Thanks for your email!
The underlying API can support both Traditional and Simplified Chinese characters.
Could you please let me know what the output of this script is:
#!/usr/bin/swift
import Foundation
let locale = NSLocale.autoupdatingCurrent
let code = locale.languageCode!
let language = locale.localizedString(forLanguageCode: code)!
print("\(code)")
print("\(language)")
We can then set the recognitionLanguages based on the output.
Modify line 52 of
main.swift
to have:request.recognitionLanguages = ["zh", "en"]Then it will work.
很不错,这个可以生效,注意:替换ocr文件后, 需要再次执行
sudo cp ocr /usr/local/bin;
,才会生效
import Foundation let locale = NSLocale.autoupdatingCurrent let code = locale.languageCode! let language = locale.localizedString(forLanguageCode: code)! print("\(code)") print("\(language)")
zh
中文
locale: Locale = {}
code: String = "zh"
language: String = "中文"
On my system supported languages right now:
So maybe you will need to put full locale name e.g. zh-Hans
or zh-Hant
BTW here the snippet to retrieve supported languages:
var possibleLanguages: Array<String> = []
let revision = VNRecognizeTextRequest.currentRevision
do {
possibleLanguages = try VNRecognizeTextRequest.supportedRecognitionLanguages(for: .accurate,
revision: revision)
} catch {
print("Error getting the supported languages.")
}
After testing on a Macbook Air w/ Big Sur, I can confirm this is a feature only available to macOS 11 and above.
Supported languages not related to Language & Region
settings. This depends on the revision
of the Vision
framework...
@h0x91b , you of course are right!
I was testing on Catalina, and it works fine on Big Sur.
We might still want to use the Language & Region to set the recognitionLanguages sort order.
I'd like to see a command line option for the languages too.
Please test with ARM: https://files.littlebird.com.au/ocr.zip
Please test with Intel Version: https://files.littlebird.com.au/ocr-XynT9NApdOnkqeCYrkLxJOHcjFpi.zip
Please note that the Chinese Support required Big Sur.
Modify line 52 of
main.swift
to have:request.recognitionLanguages = ["zh", "en"]Then it will work.
how to open this?
Please share list of supported languages and add CLI parameter to check version
["en-US", "fr-FR", "it-IT", "de-DE", "es-ES", "pt-BR", "zh-Hans", "zh-Hant"]
meet same problem.
Bigsur 11.6 Chinese mess
I can confirm working with ZH:
https://files.littlebird.com.au/Screen-Recording-2021-11-10-14-06-39.mp4