DocumentsOCR
Screenshots
Requirements
- XCode 8 +
- iOS 8.0 +
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Used frameworks
DocumentOCR framework uses
- TesseractOCR text recognition of machine readable codes
- PodAsset easy way to use pod assets
- GPUImage helps to crop image from camera
Installation
DocumentsOCR is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DocumentsOCR"
Usage
Import DocumentsOCR framework
import DocumentsOCR
Implement DocumentScannerDelegate protocol
Create your custom class, which implemets DocumentScannerDelegate protocol
class ExampleViewController: UIViewController, DocumentScannerDelegate {
func documentScanner(scanner: DocumentScanner, willBeginScanningImage image: UIImage) {
// do something with image
}
func documentScanner(scanner: DocumentScanner, didFinishScanningWithInfo info: DocumentInfo) {
// do something with DocumentInfo instance
}
func documentScanner(scanner: DocumentScanner, didFailWithError error: NSError) {
// handle error
}
// some other code here ...
}
Create DocumentScanner instance
Initialize DocumentScanner instance with references to UIViewController and DocumentScannerDelegate
var scanner = DocumentScanner(containerVC: self, withDelegate: self)
Present camera controller
Scanner instance can present view controller with camera and border (actually, container view controller will do this inside document scanner instance).
func someMethod() {
scanner.presentCameraViewController()
}
Events after "take shoot" button pressed
After take shoot button pressed, these delegate methods called:
func documentScanner(scanner: DocumentScanner, willBeginScanningImage image: UIImage)
Then if image was recognized successfull:
func documentScanner(scanner: DocumentScanner, didFinishScanningWithInfo info: DocumentInfo)
If some error happened
func documentScanner(scanner: DocumentScanner, didFailWithError error: NSError)
Author
Michael Babaev, mmbabaev@gmail.com
License
DocumentsOCR is available under the MIT license. See the LICENSE file for more info.
Issues:
Before using DocumentOCR, you must set Enable bitcode value to "No" in tesseract framework (target TesseractOCRiOS -> Build settings -> Enable Bitcode)
TODO
- documentation
- fix minor UI defects in example
- code refactoring
- pod string for all versions (without using ~> version")
- improve mr code recognition
- check visa document recognitions
- unit tests for camera shoots
- take many pictures when "take shoot" button pressed, then choose best image for recognition
