kenxdrgn
kenxdrgn

Reputation: 103

Text Recognition in Vision Framework: Issue with Multiple Languages

I'm developing an iOS application that uses the Vision framework for Optical Character Recognition (OCR). I have set up a VNRecognizeTextRequest to recognize text from images, and I've specified multiple recognition languages. Here's my code:

import Vision

let request = VNRecognizeTextRequest { (request, error) in
    if let results = request.results as? [VNRecognizedTextObservation] {
        let recognizedStrings = results.compactMap { observation in
            observation.topCandidates(1).first?.string
        }
                    
        print(recognizedStrings)
    }
}
        
request.recognitionLanguages = ["ja-JP", "ru-RU", "ko-KR", "zh-Hans", "zh-Hant", "fr-FR", "it-IT", "de-DE", "es-ES"]
request.recognitionLevel = .accurate

However, I've noticed that text recognition works perfectly for all languages except for Korean ("ko-KR") and Russian ("ru-RU").

Interestingly, when I set the recognitionLanguages array to contain only "ko-KR" or "ru-RU", text recognition works perfectly for these languages. Here's the code:

request.recognitionLanguages = ["ko-KR"] // or ["ru-RU"]

I'm trying to understand why this is happening. Could there be conflicts or confusion when the Vision framework tries to recognize text in multiple languages simultaneously, especially if the languages use different scripts or have similar characters? How does the Vision framework process multiple languages, and is there a way to improve text recognition for Korean and Russian when multiple languages are specified?

Any insights or suggestions would be greatly appreciated. Thanks in advance!

Upvotes: 2

Views: 541

Answers (0)

Related Questions