测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布日期最后发布 | 2017年8月 |
SwiftSwift 版本 | 3.1 |
SPM支持 SPM | ✗ |
由 Michael 维护。
依赖 | |
TesseractOCRiOS | ~> 4.0.0 |
PodAsset | >= 0 |
GPUImage | >= 0 |
要运行示例项目,请克隆仓库,然后从 Example 目录首先运行 pod install
。
DocumentOCR 框架使用
DocumentsOCR 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'TesseractOCRiOS', :git => 'https://github.com/appintheair/Tesseract-OCR-iOS'
pod "DocumentsOCR"
import DocumentsOCR
DocumentScannerDelegate
协议创建一个自定义类,该类实现了 DocumentScannerDelegate
协议
class ExampleViewController: UIViewController, DocumentScannerDelegate {
// required fucntions:
func documentScanner(_ scanner: DocumentScanner, didFinishScanningWithInfo info: DocumentInfo) {
// do something with DocumentInfo instance
}
func documentScanner(_ scanner: DocumentScanner, didFailWithError error: NSError) {
// handle error
}
//optional functions:
func documentScanner(_ scanner: DocumentScanner, willBeginScanningImages images: [UIImage]) {
// do something with images
}
func documentScanner(_ scanner: DocumentScanner, recognitionProgress progress: Double) {
// present current progress of recognition
}
// some other code here ...
}
DocumentScanner
实例使用对 UIViewController
和 DocumentScannerDelegate
的引用初始化 DocumentScanner
实例
var scanner = DocumentScanner(containerVC: self, withDelegate: self)
可选地,您可以设置要拍摄的照片数量和时间间隔
scanner.photosCount = 10
scanner.takePhotoInterval = 1.0
扫描仪实例可以显示带有相机和边框的视图控制器(实际上,容器视图控制器将在 DocumentScanner 实例内部完成此操作)。
func someMethod() {
scanner.presentCameraViewController()
}
点击“拍照”按钮后,设备会以takePhotoInterval
的时间间隔拍摄photosCount
张照片,然后调用以下代理方法
func documentScanner(_ scanner: DocumentScanner, willBeginScanningImages images: [UIImage])
当识别到其中一张图片时
func documentScanner(_ scanner: DocumentScanner, recognitionProgress: Double)
如果图片识别成功
func documentScanner(_ scanner: DocumentScanner, didFinishScanningWithInfo info: DocumentInfo)
如果发生某些错误
func documentScanner(_ scanner: DocumentScanner, didFailWithError error: NSError)
Michael Babaev, [email protected]
DocumentsOCR可以在MIT许可证下获得。有关更多信息,请参阅LICENSE文件。