BlinkID / blinkid-ios

Everything you need to add AI-driven ID scanning into your native iOS app.
https://microblink.com/products/blinkid
385 stars 89 forks source link

Did not run the func scanningViewController(_ scanningViewController: PPScanningViewController, didOutputMetadata metadata: PPMetadata) #52

Closed leeyikkong closed 7 years ago

leeyikkong commented 7 years ago

Hi, may I know why after scanning the id card, it wont run this method? i want to get the image from the scanning process.

Thank you

DoDoENT commented 7 years ago

Have you subscribed to receiving of metadata in the settings? In order to receive images, you must first define which metadata should be sent to the callback func.

leeyikkong commented 7 years ago
    if (PPCameraCoordinator.isScanningUnsupported(for: PPCameraType.back, error: error)) {
        return nil;
    }

    /** 1. Initialize the Scanning settings */

    // Initialize the scanner settings object. This initialize settings with all default values.
    let settings: PPSettings = PPSettings()

    /** 2. Setup the license key */

    // Visit www.microblink.com to get the license key for your app
    settings.licenseSettings.licenseKey = AppConstant.BlinkIdLicenseKey

    /**
     * 3. Set up what is being scanned. See detailed guides for specific use cases.
     * Remove undesired recognizers (added below) for optimal performance.
     */

    do { // Remove this if you're not using MRTD recognition

        // To specify we want to perform MRTD (machine readable travel document) recognition, initialize the MRTD recognizer settings
        let mrtdRecognizerSettings = PPMrtdRecognizerSettings()

        /** You can modify the properties of mrtdRecognizerSettings to suit your use-case */

        // tell the library to get full image of the document. Setting this to YES makes sense just if
        // settings.metadataSettings.dewarpedImage = YES, otherwise it wastes CPU time.
        mrtdRecognizerSettings.dewarpFullDocument = false;
        settings.metadataSettings.successfulFrame = true
        // Add MRTD Recognizer setting to a list of used recognizer settings
        settings.scanSettings.add(mrtdRecognizerSettings)
    }

this is my code, is there any problem? THank you

culoi commented 7 years ago

Hello leeyikkong, As mentioned above, you must first define which metadata should be sent to the callback func. We tested your code and added next:
func scanningViewController(_ scanningViewController: UIViewController?, didOutputMetadata metadata: PPMetadata) { let alertController: UIAlertController = UIAlertController.init(title: "Metadata", message: "Metadata OK", preferredStyle: UIAlertControllerStyle.alert) let okAction: UIAlertAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.default, handler: { (action) -> Void in self.dismiss(animated: true, completion: nil)

As we checked, there should be no problem.

If you have any additional questions, please let us know.

leeyikkong commented 7 years ago

ok thanks.