I am trying to scan some text from document. Everything was working before iOS 17.0. But after iOS update, I am not able to get proper results. Most of the times I got a single string in multiple breakup. The scan result is 30% success that is 100% with older iOS versions.
I have used Apple's Vision API for the same. Let me know if anyone else facing the same issue?
Any help will be appreciated.
Check the code snippet below for Text Recogniser:
let request = VNRecognizeTextRequest { request, error in
guard error == nil else {
completionHandler(.failure(error!))
return
}
let visionResults = request.results as! [VNRecognizedTextObservation]
let result: [TextRecognizerResult] = visionResults.map {
.init(results: $0.topCandidates(10).map { $0.string }, boundingRect: $0.boundingBox)
}
completionHandler(.success(result))
}
if let regionOfInterest = regionOfInterest {
request.regionOfInterest = regionOfInterest
}
if let minimumTextHeight = minimumTextHeight {
request.minimumTextHeight = minimumTextHeight
}
request.recognitionLevel = recognitionLevel == .fast ? .fast : .accurate
request.usesLanguageCorrection = false
let imageRequestHandler: VNImageRequestHandler
switch scanningImage {
case .cgImage(let image):
imageRequestHandler = VNImageRequestHandler(cgImage: image, orientation: orientation, options: [:])
case .pixelBuffer(let pixelBuffer):
imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: orientation, options: [:])
}
DispatchQueue.global(qos: .userInitiated).async {
do {
try imageRequestHandler.perform([request])
} catch {
completionHandler(.failure(error))
}
}