在 iOS Swift 中无法使用 Tesseract OCR
Failed to use Tesseract OCR in iOS Swift
我使用 cocoapods (pod 'TesseractOCRiOS', '4.0.0'
) 安装了 Tesseract 库并在代码中导入它没有问题,
我使用以下代码从图像中读取文本
let tesseract:G8Tesseract = G8Tesseract(language:"eng+ita")
tesseract.delegate = self
tesseract.charWhitelist = "01234567890"
tesseract.image = image
tesseract.recognize()
print(tesseract.recognizedText)
运行后第一行就崩溃了,错误是:
fatal error: unexpectedly found nil while unwrapping an Optional value
感谢任何帮助。
您的代码似乎是正确的。您可以尝试使用 if-let 条件来检查可选语句。如果您还没有,也可以在 example.
中查看
if let tesseract:G8Tesseract = G8Tesseract(language:"eng+ita") {
// Continue with you code.
}
我使用 cocoapods (pod 'TesseractOCRiOS', '4.0.0'
) 安装了 Tesseract 库并在代码中导入它没有问题,
我使用以下代码从图像中读取文本
let tesseract:G8Tesseract = G8Tesseract(language:"eng+ita")
tesseract.delegate = self
tesseract.charWhitelist = "01234567890"
tesseract.image = image
tesseract.recognize()
print(tesseract.recognizedText)
运行后第一行就崩溃了,错误是:
fatal error: unexpectedly found nil while unwrapping an Optional value
感谢任何帮助。
您的代码似乎是正确的。您可以尝试使用 if-let 条件来检查可选语句。如果您还没有,也可以在 example.
中查看if let tesseract:G8Tesseract = G8Tesseract(language:"eng+ita") {
// Continue with you code.
}