我试图在新的Swift 3.0项目中使用Tesseract-OCR-iOS。我正在使用Xcode版本8.1(8B62)。 CocoaPods是1.1.1版本。Tesseract traineddata无法在Swift 3.0项目中使用版本4.0
当我尝试使用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
到我的项目中的Xcode以外的根目录下的tessdata
文件夹并从Finder中拖到Xcode的项目浏览器参考。
一切工作正常到这一点。没有编译器错误,链接器呜呜,等等。在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。我nucked我的旧eng.traineddata文件,并从4.0回购替换它。我得到相同的错误引用相同的行。
你好,我们你能找到正确的.traineddata文件? – Lazy
使用4.0版本,但仍然在同一行中得到相同的错误 – fans3210