func visionOCR() {
// IMG_1885.PNG
guard let path = Bundle.main.path(forResource: "IMG_1885", ofType: "PNG") else {
print("Failed to find image")
return
}
guard let image = UIImage(contentsOfFile: path)?.cgImage else {
print("Failed to load image")
return
}
let reqHandler = VNImageRequestHandler(cgImage: image)
let textReq = VNRecognizeTextRequest { req, err in
guard let results = req.results else { return }
for o in results {
let o = o as? VNRecognizedTextObservation
print(o?.topCandidates(1).first?.string ?? "")
}
}
textReq.recognitionLanguages = ["ja-JP"]
textReq.automaticallyDetectsLanguage = true
textReq.usesLanguageCorrection = true
try? reqHandler.perform([textReq])
}
The above code and images work fine on iOS 17, but do not work on iOS 18 beta
Post
Replies
Boosts
Views
Activity
iOS 18 beta 3 still has this issue.