ios - App UI 将冻结 Firebase MLKit for iOS
问题描述
我有以下代码用于使用 Firebase mlkit for ios 识别文本
func runTextRecognition(with image: UIImage) {
let visionImage = VisionImage(image: image)
textRecognizer?.process(visionImage){ result, error in
guard error == nil, let result = result else {
self.addImageToView()
return
}
for block in result.blocks {
self.countDown = self.countDown + 1
let blockText = block.text
let blockFrame = block.frame
//do action
}
else{
print("Tag Total Block Count \(result.blocks.count)")
print("Tag Milena \(self.countDown)")
/*happen only with some images
countDown is less than result.blocks.count
UI will be freeze*/
if (result.blocks.count == self.countDown){
self.countDown = 0
print("Tag All Milena \(result.blocks.count)")
self.addImageToView()
}
}
}
}
}
}
当块内的文本无法识别时,有时应用程序 UI 将在循环之间冻结。我在代码中也有评论。请任何人都可以帮助我解决这个问题。
解决方案
推荐阅读
- flutter - how to limit WebviewScaffold to display limited content
- node.js - IPC using shared memory communication between two unrelated node js processes
- python - 我应该怎么做才能更正此代码?作为输出,我必须获得无效输入,然后是最大值和最小值
- wordpress - Ninja Forms 服务器端验证不起作用
- c# - 具有多个 URL 的 HttpWebResponse 导致错误
- codenameone - 代号一逆向工程师安卓包
- c# - 找不到类型或命名空间名称“硬件”(您是否缺少 using 指令或程序集引用?)
- python - 如何在 python 中实现凯撒密码?
- bash - 为什么从 cli 运行 aws update-service 会导致弹出类似 vim 的窗口,需要一些输入?
- range - 如何在 Tableau 条形图中显示工资范围