Skip to main content

Disability Certificate Recognizer | iOS Document Scanner

The Scanbot SDK provides the ability to recognize disability certificates in a UIImage or CMSampleBufferRef. The result is encapsulated in SBSDKDisabilityCertificatesRecognizerResult instance.

The Disability Certificate Recognizer is based on the OCR feature and thus requires the proper installation of the OCR language file eng.traineddata (aka. blob file). For more details on how to set up the OCR language files please refer to the OCR section.

You can integrate the component into the application using:

Ready-To-Use UI Component#

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

Usually this view controller is used as a separate screen for scanning various scanning scenarios e.g. Disability Certificate scanning.

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

import UIKitimport ScanbotSDK
class DisabilityCertificateScanWorkflowUISwiftViewController: 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 = SBSDKUIWorkflowScannerConfiguration.default()
        // Behavior configuration:        // e.g. enable a beep sound on successful detection.        configuration.behaviorConfiguration.isSuccessBeepEnabled = true
        // UI configuration:        // e.g. configure various colors.        configuration.uiConfiguration.topBarBackgroundColor =        configuration.uiConfiguration.topBarButtonsActiveColor = UIColor.white        configuration.uiConfiguration.topBarButtonsInactiveColor = UIColor.white.withAlphaComponent(0.3)
        // Text configuration:        // e.g. customize a UI element's text.        configuration.textConfiguration.cancelButtonTitle = "Cancel"
        // Create an array with the accepted aspect ratios        // e.g. aspect ratios used for German disability certificates.        let ratios = [SBSDKAspectRatio(width: 1.0, andHeight: 1.414),                      SBSDKAspectRatio(width: 1.414, andHeight: 1.0),                      SBSDKAspectRatio(width: 1.0, andHeight: 1.5715)]
        // Create a workflow step using the accepted aspect ratios.        let workflowStep = SBSDKUIScanDisabilityCertificateWorkflowStep(title: "Scan Disability Certificate",                                                                        message: "Please scan your disability certificate.",                                                                        requiredAspectRatios: ratios,                                                                        wantsCapturedPage: true) { result in            // Process the result of the workflow step.            if let dcCertificate = result.disabilityCertificateResult, dcCertificate.recognitionSuccessful {
                // Return nil if a disability certificate was found and recognized.                return nil            }
            // Handle the error if no disability certificate was found or recognized.            return NSError(domain: "DCCertificateErrorDomain",                           code: 2,                           userInfo: [NSLocalizedDescriptionKey: "This does not seem to be a valid certificate."])        }
        // Create a workflow using a disability certificate workflow step.        let workflow = SBSDKUIWorkflow(steps: [workflowStep],                                       name: "Disability Certificate",                                       validationHandler: nil)
        // Present the recognizer view controller modally on this view controller.        SBSDKUIWorkflowScannerViewController.present(on: self,                                                     workflow: workflow!,                                                     configuration: configuration,                                                     delegate: self)    }}
extension DisabilityCertificateScanWorkflowUISwiftViewController: SBSDKUIWorkflowScannerViewControllerDelegate {    func workflowScanViewController(_ viewController: SBSDKUIWorkflowScannerViewController,                                    didFinish workflow: SBSDKUIWorkflow,                                    with results: [SBSDKUIWorkflowStepResult]) {        // Process the result of the workflow.    }}