【发布时间】:2017-04-29 02:28:51
【问题描述】:
我正在尝试在新的 Swift 3.0 项目中使用 Tesseract-OCR-iOS。我正在使用 Xcode 版本 8.1 (8B62)。 CocoaPods 是 1.1.1 版本。
当我尝试使用 tesseract.recognize() 时,我的应用程序崩溃并且我在控制台中得到以下输出:
actual_tessdata_num_entries_ <= TESSDATA_NUM_ENTRIES:Error:Assert failed:in file tessdatamanager.cpp, line 53
我找到了this post,听起来我使用了错误版本的traineddata。我从the tesseract-ocr/tessdata repo 下载了tessdata,所以我很困惑为什么我的版本号不匹配。
非常感谢任何关于如何让 Tesseract 工作的建议。以下是关于:我的设置的附加信息。
这是我的Podfile 的样子:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'TesseractDemo' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for TesseractDemo
pod 'TesseractOCRiOS', '4.0.0'
end
我已将包含 eng.traineddata 的 tessdata 文件夹拖到 Xcode 外部项目的根目录中,并将 reference 从 Finder 拖到 Xcode 的 Project Navigator。
到目前为止一切正常。没有编译器错误、链接器抱怨等。在 UIViewController 中,我正在导入 TesseratOCR 并像这样调用它:
// MARK: - OCR Methods
func scanImage(image: UIImage) {
if let tesseract = G8Tesseract(language: "eng") {
tesseract.delegate = self
tesseract.image = imageToScan?.g8_blackAndWhite()
tesseract.recognize()
textView.text = tesseract.recognizedText
}
}
更新 我找到了一个指向repo of traineddata files for version 4.0 的链接。我对旧的 eng.traineddata 文件进行了核对,并将其替换为 4.0 存储库中的文件。引用同一行时出现相同的错误。
【问题讨论】:
-
您好,您能找到正确的 .traineddata 文件吗?
-
使用了 4.0 版,但在同一行仍然出现同样的错误