Skip to main content

License Plate Scanner | iOS Document Scanner

A class to scan a vehicle's license plate in a UIImage or CMSampleBufferRef and run a validation on the result. Ideally you use an instance of this class on subsequent video frames. Each scanned frame will raise the confidence of the scan.

License Plate Scanner UI#

There are two ways to integrate the component into the application:

Classical UI Component#

The main class of the Classical UI component is SBSDKLicensePlateScannerViewController.

Usually this view controller is embedded as a child view controller into another view controller, the parent view controller. The parent view controller usually acts as the delegate and processes the recognition results. You still have full control over the UI elements and can add additional views and buttons to your view controller. The classical component does not display results, instead it just forwards them to the delegate.

import UIKitimport ScanbotSDK
class LicensePlateScannerSwiftViewController: UIViewController {
    // The instance of the scanner view controller.    var scannerViewController: SBSDKLicensePlateScannerViewController?
    override func viewDidLoad() {        super.viewDidLoad()
        // Create the SBSDKLicensePlateScannerConfiguration object.        let configuration = SBSDKLicensePlateScannerConfiguration()
        // Set the maximum number of accumulated frames before starting recognition.        configuration.maximumNumberOfAccumulatedFrames = 5
        // Create the SBSDKLicensePlateScannerViewController instance.        self.scannerViewController = SBSDKLicensePlateScannerViewController(parentViewController: self,                                                                            parentView: self.view,                                                                            delegate: self,                                                                            configuration: configuration)    }
extension LicensePlateScannerSwiftViewController: SBSDKLicensePlateScannerViewControllerDelegate {    func licensePlateScannerViewController(_ controller: SBSDKLicensePlateScannerViewController,                                           didRecognizeLicensePlate licensePlateResult: SBSDKLicensePlateScannerResult,                                           on image: UIImage) {        // Process the recognized result.    }}

Ready-To-Use UI Component#

The main class of the Ready-To-Use UI (RTU UI) component is SBSDKUILicensePlateScannerViewController.

Usually this view controller is used as a separate screen for scanning license plates in a UIImage or CMSampleBufferRef. It returns the recognition results in a delegate method.

While you don't have direct control of the actual scanner view controller you can use the SBSDKUILicensePlateScannerConfiguration to customize it in a variety of ways, such as colors, texts and behavior.

import UIKitimport ScanbotSDK
class LicensePlateScannerUISwiftViewController: UIViewController {
    override func viewDidAppear(_ animated: Bool) {        super.viewDidAppear(animated)
        // Start scanning here. Usually this is an action triggered by some button or menu.        self.startScanning()    }
    func startScanning() {
        // Create the default configuration object.        let configuration = SBSDKUILicensePlateScannerConfiguration.default()
        // Behavior configuration:        // e.g. set the maximum number of accumulated frames before starting recognition.        configuration.behaviorConfiguration.maximumNumberOfAccumulatedFrames = 5
        // UI configuration:        // e.g. configure various colors.        configuration.uiConfiguration.topBarBackgroundColor =        configuration.uiConfiguration.topBarButtonsColor = UIColor.white        configuration.uiConfiguration.topBarButtonsInactiveColor = UIColor.white.withAlphaComponent(0.3)
        // Text configuration:        // e.g. customize a UI element's text.        configuration.textConfiguration.cancelButtonTitle = "Cancel"
        // Present the recognizer view controller modally on this view controller.        SBSDKUILicensePlateScannerViewController.present(on: self,                                                         configuration: configuration,                                                         andDelegate: self)    }}
extension LicensePlateScannerUISwiftViewController: SBSDKUILicensePlateScannerViewControllerDelegate {    func licensePlateScanner(_ controller: SBSDKUILicensePlateScannerViewController,                             didRecognizeLicensePlate result: SBSDKLicensePlateScannerResult) {        // Process the scanned result.    }}