You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is Text Detection on iOS using Vision built-in model. If you are interested in iOS + Machine Learning, visit here you can see various DEMOs.
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
varrequest:VNDetectTextRectanglesRequest?
3.3 Configure and prepare
overridefunc viewDidLoad(){
super.viewDidLoad()letrequest=VNDetectTextRectanglesRequest(completionHandler:self.visionRequestDidComplete)
request.reportCharacterBoxes =trueself.request = request
}func visionRequestDidComplete(request:VNRequest, error:Error?){
/* ------------------------------------------------------ */
/* something postprocessing what you want after inference */
/* ------------------------------------------------------ */
}
3.4 Inference 🏃♂️
// on the inference point
lethandler=VNImageRequestHandler(cvPixelBuffer: pixelBuffer)iflet request = request {try? handler.perform([self.request])}