Awesome
TextDetection-CoreML
This project is Text Detection on iOS using Vision built-in model.<br>If you are interested in iOS + Machine Learning, visit here you can see various DEMOs.<br>
Requirements
- Xcode 9.2+
- iOS 12.0+
- Swift 4.2
Performance
Inference Time
device | inference time |
---|---|
iPhone X | 10 ms |
Build & Run
1. Prerequisites
Add permission in info.plist for device's camera access
2. Dependencies
No external library yet.
3. Code
3.1 Import Vision framework
import Vision
3.2 Define properties for Vision
// properties on ViewController
var request: VNDetectTextRectanglesRequest?
3.3 Configure and prepare
override func viewDidLoad() {
super.viewDidLoad()
let request = VNDetectTextRectanglesRequest(completionHandler: self.visionRequestDidComplete)
request.reportCharacterBoxes = true
self.request = request
}
func visionRequestDidComplete(request: VNRequest, error: Error?) {
/* ------------------------------------------------------ */
/* something postprocessing what you want after inference */
/* ------------------------------------------------------ */
}
3.4 Inference 🏃♂️
// on the inference point
let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer)
if let request = request {
try? handler.perform([self.request])
}