


delegate = self present(scannerViewController, animated: true) Creating and presenting the view controllerĬreating and presenting the VNDocumentCameraViewController just takes a few lines of code, like this: let scannerViewController = VNDocumentCameraViewController() scannerViewController. To use the document scanning view controller, we have to present it and conform to the VNDocumentCameraViewControllerDelegate in our view controller to respond to callbacks such as the user tapping Cancel. It handles detecting documents, performing perspective correction (to rotate documents that aren’t perfectly straight), and enhancing documents to make them look good. IOS 13 adds a new framework named VisionKit which has a document scanning view controller, similar to the one used in Notes. For example, “This app uses the Camera to allow you to scan documents”. To fix this, just add a key named NSCameraUsageDescription to your ist, and, for the value, put whatever is appropriate for your app. If your app attempts to access the camera without this description, iOS will crash the app immediately. As our app will use the camera to scan documents, we need to add a description of what we use the camera for to our ist. However, iOS shows a permission prompt when apps try to access the camera.
Ocr scanner ios app install#
Since we’ll only be using Vision and VisionKit, which are Apple’s frameworks and built into iOS, we don’t need to install any third party libraries. If you don’t have an existing Xcode project to use, go ahead and create a new project with the “Single View App” template, which works well for our needs. There, you’ll find a source code mobile app, written in pure Swift, containing all of the examples from this tutorial.
Ocr scanner ios app full#
If you’d prefer to jump straight to a full demo app, feel free to click here to go to the CodeCanyon. In iOS 13, Apple’s Vision framework also adds support for OCR (Optical Character Recognition), which allows you to detect and recognize text on scanned documents! Instead of having to manually detect and adjust documents, VisionKit handles everything for you, letting you focus on your app. VisionKit is a new framework Apple introduced in iOS 13 that lets your app use the system’s document scanner to scan documents or papers. Scanning documents with Vision and VisionKit on iOS 13
