我正在尝试从名为“quote”的 Assets 文件夹中的图像中读取文本。但是每次都打印出错误“错误 2:无法处理 VisionImage”。
如何确保正确处理 VisionImage 并从图像“报价”中获取文本?
let vision = Vision.vision()
let textRecognizer = vision.cloudTextRecognizer()
let options = VisionCloudTextRecognizerOptions()
options.languageHints = ["en", "hi"]
guard let img = UIImage(named: "quote")
else {
print("error 1: image not there")
return
}
let visionImage = VisionImage(image: img)
textRecognizer.process(visionImage) { result, error in
guard error == nil, let result = result else {
print("error 2: unable to process VisionImage")
return
}