- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 Firebase MLKit 对我的图像进行 OCR,但失败并返回错误
Text detection failed with error: Failed to run text detector because self is nil.
/// Detects texts on the specified image and draws a frame for them.
func detectTexts() {
let image = #imageLiteral(resourceName: "testocr")
// Create a text detector.
let textDetector = vision.textDetector() // Check console for errors.
// Initialize a VisionImage with a UIImage.
let visionImage = VisionImage(image: image)
textDetector.detect(in: visionImage) { (features, error) in
guard error == nil, let features = features, !features.isEmpty else {
let errorString = error?.localizedDescription ?? "No results returned."
print("Text detection failed with error: \(errorString)")
return
}
// Recognized and extracted text
print("Detected text has: \(features.count) blocks")
let resultText = features.map { feature in
return "Text: \(feature.text)"
}.joined(separator: "\n")
print(resultText)
}
}
最佳答案
看起来您需要保持对 textDetector
的强引用,否则检测器会在调用完成 block 之前被释放。
稍微更改一下代码:
var textDetector: VisionTextDetector? // NEW
/// Detects texts on the specified image and draws a frame for them.
func detectTexts() {
// ... truncated ...
textDetector = vision.textDetector() // NEW
let visionImage = VisionImage(image: image)
textDetector?.detect(in: visionImage) { (features, error) in // NEW
// Callback implementation
}
}
你也可以解开它以确保它在你赋值后不为 nil:
guard let textDetector = textDetector else {
print("Error: textDetector is nil.")
return
}
希望对您有所帮助!
关于ios - Firebase MLKit 文本识别错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50246800/
我实现了 firebase MLKit 来扫描 QRCode,它正在扫描,但它正在扫描屏幕上的所有 QRcode。我只需要扫描中心捕获的 QRCode(中心有箭头 ImageView),我该怎么做?
Google 的 MLKit(没有 Firebase)是新的,所以我遇到了麻烦。我在这里尝试遵循此示例:https://developers.google.com/ml-kit/vision/obje
您好,我正在使用没有带有 androidx 的 firebase 的 android mlkit 条码扫描仪,我遵循此代码 https://medium.com/@surya.n1447/google
我一直在关注有关适用于 iOS 的 Firebase MLKit 文本识别 (OCR) 的链接,它似乎工作正常,但所选照片(通过相机或图库)是纵向拍摄时除外。处理肖像照片时,图像上未检测到任何内容。
我正在寻找在我的 Android 应用程序中实现 MLKit 人脸识别库。我唯一不明白的是是否有可能以及如何比较两张照片并检测它们是否是同一个人。 我已经阅读了这些指南: https://fireba
我正在开发一个应用程序来从营养成分中提取文本。通过使用 MLkit firebase 我实现了这一点,但我有一个问题,文本的显示格式与图像中的格式不同。这是我的文本识别代码。
我需要在 Android 应用程序中执行相机预览操作,以查找矩形并处理它们。如何使用 Firebase MLKit 实现此目标? 旁注:我知道如何使用 OpenCV 来做到这一点,但是即使是轻量级计算
我正在通过此链接使用快速入门 firebase MLKIT 实现-> https://github.com/ankitjamuar/android-firebase-mlkit 但是当我找到MLKIT
我使用 sklearn 创建了一个多项式朴素贝叶斯,并将其编写在 jupiter 模型上,并通过 joblib 库将其保存为 sav 扩展文件。现在,我想将其上传到 MLKit 中,以便将来使用它连接
我有一个名为 MLVision 的类来处理文本识别。 class MLVision { lazy var vision = Vision.vision() var textRecogn
开始使用带有前置摄像头的 MLKit 人脸检测器,但处理人脸的速度非常慢 func captureOutput(_ output: AVCaptureOutput, didOutput sampleB
我正在尝试使用 Firebase MLKit 对我的图像进行 OCR,但失败并返回错误 Text detection failed with error: Failed to run text det
我正在使用 FireBase MLkit 扫描我的 Android 应用程序的条码。 FirebaseVisionBarcode 以整数格式返回条形码类型(即其编码)。但是有什么办法可以让我获得条形码
我正在尝试使用 firebase MLKit 检测对象和文本在 android 中的实时相机提要上。有特定的识别器( FirebaseVisionTextRecognizer , FirebaseVi
我想在使用 google vision api 时减少减少条形码跟踪窗口。有一些答案here但他们觉得有点过时了。 我正在使用谷歌的示例:https://github.com/googlesample
我正在尝试检测下面某些设备的数字 LED 显示屏上的文本,并且需要帮助来完成这项工作。我尝试了 Google 随 firebase ML 套件提供的文本检测示例,但在设备(而非云)上表现不佳。帮助我了
我有最新的 pod 版本 1.5.2,但是我无法从 firebase 安装 ml 工具包,我明白了: Analyzing dependencies [!] CocoaPods could not
您好,我有一个自定义模型,我在 Android 应用程序中使用它,但是当我尝试运行它时,抛出了一个 MLkitExceptions,该错误的日志输出如下: Internal error has occ
因此,我正在尝试使用 MLKit 扫描条码,但是 self.barcodeDetector?.detect 的完成 block 中的条码变量中没有条码。 UIImage(命名为:“barcode.jp
我想识别和计算图片中的物体,例如计算邻里图片中的房屋数量。使用 ML Kit 执行此操作的最佳方法是什么? 我需要使用 Object Detection API 吗? ?或者是否有可能使用直接的图像标
我是一名优秀的程序员,十分优秀!