Closed YogeshBharate closed 5 years ago
Hi @YogeshBharate,
could you replicate this behaviour on one of the sample apps? I'm not sure what you mean by killing the application, do you mean closing it to background or kill the app completely?
I tried to recreate it using this code, it's a modified ViewController.swift file from BlinkID-sample-Swift demo app in the repo:
import UIKit
import MicroBlink
class ViewController: UIViewController {
var uaeRecognizerFront : MBUnitedArabEmiratesIdFrontRecognizer!
var uaeRecognizerBack : MBUnitedArabEmiratesIdBackRecognizer!
var barcodeOverlayViewController: MBDocumentOverlayViewController!
override func viewDidLoad() {
super.viewDidLoad()
// Valid until: 2019-02-07
MBMicroblinkSDK.sharedInstance().setLicenseResource("blinkid-license", withExtension: "txt", inSubdirectory: "", for: Bundle.main)
}
@IBAction func didTapScan(_ sender: AnyObject) {
// To specify we want to perform MRTD (machine readable travel document) recognition, initialize the MRTD recognizer settings
uaeRecognizerFront = MBUnitedArabEmiratesIdFrontRecognizer()
uaeRecognizerBack = MBUnitedArabEmiratesIdBackRecognizer()
/** Create usdl recognizer */
/** Create barcode settings */
let settings : MBDocumentOverlaySettings = MBDocumentOverlaySettings()
/** Crate recognizer collection */
let recognizerList = [uaeRecognizerFront, uaeRecognizerBack] as [MBRecognizer]
let recognizerCollection : MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList)
/** Create your overlay view controller */
barcodeOverlayViewController = MBDocumentOverlayViewController(settings: settings, recognizerCollection: recognizerCollection, delegate: self)
/** Create recognizer view controller with wanted overlay view controller */
let recognizerRunneViewController : UIViewController = MBViewControllerFactory.recognizerRunnerViewController(withOverlayViewController: barcodeOverlayViewController)
/** Present the recognizer runner view controller. You can use other presentation methods as well (instead of presentViewController) */
self.present(recognizerRunneViewController, animated: true, completion: nil)
}
}
extension ViewController: MBDocumentOverlayViewControllerDelegate {
func documentOverlayViewControllerDidFinishScanning(_ documentOverlayViewController: MBDocumentOverlayViewController, state: MBRecognizerResultState) {
/** This is done on background thread */
documentOverlayViewController.recognizerRunnerViewController?.pauseScanning()
var message: String = ""
var title: String = ""
if uaeRecognizerFront.result.resultState == .valid && uaeRecognizerBack.result.resultState != .valid {
let recognizerList = [uaeRecognizerBack] as [MBRecognizer]
let recognizerCollection : MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList)
barcodeOverlayViewController.reconfigureRecognizers(recognizerCollection)
documentOverlayViewController.recognizerRunnerViewController?.resumeScanningAndResetState(true)
} else if uaeRecognizerFront.result.resultState != .valid && uaeRecognizerBack.result.resultState == .valid {
let recognizerList = [uaeRecognizerFront] as [MBRecognizer]
let recognizerCollection : MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList)
barcodeOverlayViewController.reconfigureRecognizers(recognizerCollection)
documentOverlayViewController.recognizerRunnerViewController?.resumeScanningAndResetState(true)
} else if uaeRecognizerFront.result.resultState == .valid && uaeRecognizerBack.result.resultState == .valid {
message = uaeRecognizerFront.description + uaeRecognizerBack.description
title = "UAE"
DispatchQueue.main.async {
// present the alert view with scanned results
let alertController: UIAlertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
let okAction: UIAlertAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.default,
handler: { (action) -> Void in
let recognizerList = [self.uaeRecognizerFront, self.uaeRecognizerBack] as [MBRecognizer]
let recognizerCollection : MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList)
documentOverlayViewController.reconfigureRecognizers(recognizerCollection)
documentOverlayViewController.recognizerRunnerViewController?.resumeScanningAndResetState(true)
})
alertController.addAction(okAction)
documentOverlayViewController.present(alertController, animated: true, completion: nil)
}
}
}
func documentOverlayViewControllerDidTapClose(_ documentOverlayViewController: MBDocumentOverlayViewController) {
}
}
This works, when I close the app and return to it, it still works and scans normally. Can you send me this code but modified so I can use it to recreate the issue?
Kind regards, Jure
@jcular - Killing the app completely.
func recognizerRunnerViewController(_ recognizerRunnerViewController: UIViewController & MBRecognizerRunnerViewController, didFinishScanningWith state: MBRecognizerResultState) {
if state == MBRecognizerResultState.valid {
recognizerRunnerViewController.pauseScanning()
recognizerRunnerViewController.playScanSuccessSound()
DispatchQueue.main.async {[weak self] in
guard let recognizerList = self?.recognizerCollection.recognizerList else {
// Show Alert here
return
}
for recognizer in recognizerList where recognizer.baseResult?.resultState == MBRecognizerResultState.valid {
if recognizer is MBUnitedArabEmiratesIdFrontRecognizer, let frontSideRecognizer = recognizer as? MBUnitedArabEmiratesIdFrontRecognizer {
self?.scanAreaCentralLabel.text = ScanEmiratesIdStrings.info.backSidePlaceholder
self?.frontSideModel = ScanEmiratesIdParser.getEmiratesIdFrontSideData(frontSideRecognizer.result)
self?.switchToScanningBackSide()
recognizerRunnerViewController.resumeScanningAndResetState(true)
} else if recognizer is MBUnitedArabEmiratesIdBackRecognizer, let backSideRecognizer = recognizer as? MBUnitedArabEmiratesIdBackRecognizer {
// Make the object here self?.backSideModel = ScanEmiratesIdParser.getEmiratesIdBackSideData(backSideRecognizer.result) self?.navigateToNextScreen(true) } } } } }
Above code which I used to make the object of Emirates Id.
As I get the image object for back image i.e MBUnitedArabEmiratesIdBackRecognizerResult.fullDocumentImage?.image of UAE ID is nil after scanning back side of UAE Id. That why the application stop working.
Hi @YogeshBharate,
can you send the code that you use to setup recognizers?
Both before scanning front side and the one in switchToScanningBackSide
func.
Also does this happen all the time, or sometimes when you quit the app and launch it again?
This might happen if there's a case where you don't set returnFullDocumentImage
to true.
Kind regards, Jure
@jcular
func switchToScanningBackSide() { currentEmiratesIdSide = .back emiratesIdBackSide = MBUnitedArabEmiratesIdBackRecognizer() emiratesIdBackSide.fullDocumentImageDpi = 400 emiratesIdBackSide.returnFullDocumentImage = true let recognizerList = [emiratesIdBackSide] as [MBRecognizer] let recognizerCollection: MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList) self.reconfigureRecognizers(recognizerCollection) } Above is the switchToScanningBackSide() to scan the back page of UAE ID. Let me know if I missed something. I have uploaded the sample demo code into the Support Ticket.
I am using Microblink SDK iOS version 4.4.0. When I launch the application and scan the UAE ID for the first time. It will scan the front as well as a back page of UAE ID.
When I killed the application and relaunch again, get the nil value for MBUnitedArabEmiratesIdBackRecognizerResult.fullDocumentImage?.image.
Please look into this issue.