Tesseract使用4.0版本训练数据无法在Swift 3.0项目中工作

Adr*_*ian 25 ocr tesseract ios swift

我正在尝试在新的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
Run Code Online (Sandbox Code Playgroud)

我发现这篇文章,听起来我使用的是错误的版本traineddata.我tessdatatesseract-ocr/tessdata repo下载,所以我很困惑为什么我的版本号不匹配.

任何建议如何让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
Run Code Online (Sandbox Code Playgroud)

我已将tessdata包含eng.traineddata在Xcode之外的项目根目录中的文件夹拖放到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
    }
}
Run Code Online (Sandbox Code Playgroud)

更新 我找到了4.0版本的训练数据文件回购链接.我修改了我的旧eng.traineddata文件,并将其替换为4.0 repo中的文件.我得到引用相同行的相同错误.

Adr*_*ian 39

eng.traineddataGitHub上面链接的当前版本不适用于当前版本的Tesseract-OCR-iOS.

如果您有正确的<language>.traineddata文件,GitHub上发布的安装说明将完美运行.

eng.traineddataRay Wenderlich的Lyndsey Scott精彩的Tesseract教程中拖出来后,我发现了这一点.

这个repo包含了eng.traineddata让Tesseract工作所需的文件.我不确定这是否适用于所有语言.