private void InitializeBlinkIdScanner() { var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); string licenseKey = string.Empty; if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEQY29tLmNobWwuaXQuY2Nmc0iUtoUk/ef1YJ5j3+j5toBM9aJu3EN0SDbB/mPKFx+V0MNFRZwwmNkzl1VU8JhdIYmouNK1poJKQCdOpB6MZ7W1x/pIarGykttt1FFrEHkvAE0NW8NEmidSg8mY+FCvJWVAiQlOHsSXw5YbyjtZv1lGDrU6zai0qefO7+VpwI3w2Q4GwlVybN7SlkSoU1vb8zh0y5Gc2eC5vVDyi7XoSZY/L1lUD1VsBWya5RBti4r7QzPEPy9M/WZp8TNJrw=="; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4oIhH4ywlU8/Zqc2tpXY3x6Jq4MYktFtYaRbzI3x0Qxrr0NeFEjL6qt8Qcz144x2F5LGg1bHXgkRXbt37saoFv1HJUiJ50Y4YHglH8SqhyfSzsT/C/vQEAKXgZBQuNeeCTY6RttMciEbHHHj7nybEz9+aOoBXfx0+XXx3cU4L6Wbmf/5EAXokQXtEkL3mCR8VC/51ohQVyRIgItohusasIcfe8B+UjUMCZU9v1B0bvHcUKZH6g=="; } blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); mrtdRecognizer = DependencyService.Get <IMrtdRecognizer>(); mrtdRecognizer.ReturnFullDocumentImage = true; mrtdSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(mrtdRecognizer); // subscribe to scanning done message MessagingCenter.Subscribe <Microblink.Forms.Core.Messages.ScanningDoneMessage>(this, Microblink.Forms.Core.Messages.ScanningDoneMessageId, (sender) => { string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; ScanResult = result.MrzResult; SelectedIDMethod = Constants.IdentificationMethods.FirstOrDefault(x => x.Code == "2"); if (result.MrzResult.Gender == "F") { SelectedGender = Constants.Genders.FirstOrDefault(x => x.Gender == "Female"); } else { SelectedGender = Constants.Genders.FirstOrDefault(x => x.Gender == "Male"); } IsVisibleGuestInformation = true; IsVisibleHint = false; IsVisiblePage = true; IsVisibleIndicator = false; IsRunningIndicator = false; //FullDocumentImge = result.FullDocumentImage; //FrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; } } }); }
public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDF2B9jpa6FeAx5h89osjSFXqQRtWjes0WSEXe3rubgFApHsFdSF2oJZL0MhSL18AgbaLmPiOT3RFu+lqtKtpsjqRfxEVmc9cU98GnjciEeAOC331OUeT5R1p7zKqsenX/3IytQJuMG4ruEaRXc5746y/Kv8ch0XDgv/nRu4siNlvpkjsUjkeyokbUUwi+uzL6t2G4V/sX0SXTMWPjG7zjtW4ovwpGs6fct/dpBJQfzRQNCn9kg=="; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4oIhH4ywlU8/ZIc8ttT74daTKaSlmN1khLj7e+CR+5SB1pjJQuNbEIlPAVl67d85JYqkRXxuWzKbaSWuPI7MzpKrXphakcSuyLYATcHaZMHh2rJvFFfYWXEWz6GZJSRk4TZmdqWBsjdNEJBe2F8hb/CEuKgkZkoESgLsCEYWf6Se+IkRBhRcmmOrcqJAf5YzhNbhlClR7GmNEPZheayI+i784TvIAnHFGloQF52KSF8YFm3dTw=="; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // license keys must be set before creating Recognizer, othervise InvalidLicenseKeyException will be thrown // the following code creates and sets up implementation of MrtdRecognizer mrtdRecognizer = DependencyService.Get <IMrtdRecognizer>(); mrtdRecognizer.ReturnFullDocumentImage = true; // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations mrtdSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(mrtdRecognizer); // the following code creates and sets up implementation of UsdlRecognizer usdlRecognizer = DependencyService.Get <IUsdlRecognizer>(); // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations usdlSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(usdlRecognizer); // the following code creates and sets up implementation of EudlRecognizer eudlRecognizer = DependencyService.Get <IEudlRecognizer>(); eudlRecognizer.ReturnFaceImage = true; eudlRecognizer.ReturnFullDocumentImage = true; // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations eudlSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(eudlRecognizer); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; stringResult = "PrimaryID: " + result.MrzResult.PrimaryId + "\n" + "SecondaryID: " + result.MrzResult.SecondaryId + "\n" + "Nationality: " + result.MrzResult.Nationality + "\n" + "Gender: " + result.MrzResult.Gender + "\n" + "Date of birth: " + result.MrzResult.DateOfBirth.Day + "." + result.MrzResult.DateOfBirth.Month + "." + result.MrzResult.DateOfBirth.Year + "."; fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; } // similarly, we can check for results of other recognizers if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = usdlRecognizer.Result; stringResult = "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + "Height: " + result.GetField(UsdlKeys.Height) + "\n" + "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // License information "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; } if (eudlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = eudlRecognizer.Result; stringResult = "First name: " + result.FirstName + "\n" + "Last name: " + result.LastName + "\n" + "Address: " + result.Address + "\n" + "Personal number: " + result.PersonalNumber + "\n" + "Driver number: " + result.DriverNumber; successFrameImageSource = eudlSuccessFrameGrabberRecognizer.Result.SuccessFrame; faceImageSource = result.FaceImage; fullDocumentImageSource = result.FullDocumentImage; } } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentImage.Source = fullDocumentImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
/// <summary> /// USDL recognizer will be used for scanning barcode from back side of United States' driver's licenses. /// </summary> //IUsdlRecognizer usdlRecognizer; /// <summary> /// This success frame grabber recognizer will wrap usdlRecognizer and will contain camera frame of the moment /// when wrapped recognizer finished its recognition. /// </summary> //ISuccessFrameGrabberRecognizer usdlSuccessFrameGrabberRecognizer; public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAx7x69Nn9VVTofYT2ZAb8+dDWUdwnBje1AqOjCH2Ckp78A0XKEBbg91lC3vJyWALjcuZHPeESnd+JI2IzBQbP/32HhRBLJaXyZxbOtTwNFBnadltFIf2AGL+FDIFJz3bc6VWOEA3ImT7S02gnAaYMS3Gy7PnIYJr33JHe+qOKzSUtESQLVIbMQp1+ubP7hh+/g3z2Vb8LRA0i2n/x/YRcqmA0bDe5oA3Ww39I/6O2PNGX/PNhLDkaVpbX3RYof5cx"; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4mAhH4ywlU8/ZLMbELfv07jxSZleylhrg1TGwLmMBn5fZzgRlTqfMhHKbgNdNH8IJHQ1mGk1G8abt0/uz7tlBNYzwc4XRcsyzkY7MlR5ZDN3TyjzwprvDNDO7CVGeB4712YCJ/Khbn8wpymaHZwKXSjq8BkkdKfJWD5sE0/eauWRH/SQ1HVZ0SIbNs/Z5lwyXcPIFCFRLKIMUb/fxFsg8bcP5W8WdIPEP+t7PzWiMcEFPgpcqAmp395nooYWCQt8W7yqOGX4WAY4"; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentFrontImageSource = null; ImageSource fullDocumentBackImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (blinkidRecognizer.Result.ResultState == RecognizerResultState.Valid) { var blinkidResult = blinkidRecognizer.Result; stringResult = "BlinkID recognizer result:\n" + "FirstName: " + blinkidResult.FirstName + "\n" + "LastName: " + blinkidResult.LastName + "\n" + "Address: " + blinkidResult.Address + "\n" + "DocumentNumber: " + blinkidResult.DocumentNumber + "\n" + "Sex: " + blinkidResult.Sex + "\n"; var dob = blinkidResult.DateOfBirth; if (dob != null) { stringResult += "DateOfBirth: " + dob.Day + "." + dob.Month + "." + dob.Year + ".\n"; } var doi = blinkidResult.DateOfIssue; if (doi != null) { stringResult += "DateOfIssue: " + doi.Day + "." + doi.Month + "." + doi.Year + ".\n"; } var doe = blinkidResult.DateOfExpiry; if (doe != null) { stringResult += "DateOfExpiry: " + doe.Day + "." + doe.Month + "." + doe.Year + ".\n"; } // there are other fields to extract fullDocumentFrontImageSource = blinkidResult.FullDocumentFrontImage; fullDocumentBackImageSource = blinkidResult.FullDocumentBackImage; } // similarly, we can check for results of other recognizers //if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) //{ // var result = usdlRecognizer.Result; // stringResult = // "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + // "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + // "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + // "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + // "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + // "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + // "Height: " + result.GetField(UsdlKeys.Height) + "\n" + // "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + // "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + // "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + // "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // // License information // "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + // "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + // "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + // "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + // "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + // "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + // "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + // "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); // successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; //} } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentFrontImage.Source = fullDocumentFrontImageSource; fullDocumentBackImage.Source = fullDocumentBackImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
/// <summary> /// USDL recognizer will be used for scanning barcode from back side of United States' driver's licenses. /// </summary> //IUsdlRecognizer usdlRecognizer; /// <summary> /// This success frame grabber recognizer will wrap usdlRecognizer and will contain camera frame of the moment /// when wrapped recognizer finished its recognition. /// </summary> //ISuccessFrameGrabberRecognizer usdlSuccessFrameGrabberRecognizer; public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAwozaXbqHSjMIKiqr4gD/bDmTXR0NcEQJxc98SUF7C/K1YYrbRc9ZVNfHdRwd2qQ35aa2PuyWiKisBm8am48D1N18uu0lylVoMkeqYf9Z/ggNP8nZkVRfY1y9egl01baFvPskSw4/5vt7fodsrK3XDMu+HUmeWVDqizB0jRwzh4Yu40AqOUTMYWVN3WgfSLQdWHlYKu2CFVTj83CYvNeGMQs+KTTEXvKiKmHSzhNeER9CVfoDC/qgXJV0kvdLO5+q0c4i"; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4mAhH4ywlU8/YXsbFGl/R9gKNbvPnYoH1UX6O/hI3oLNiy4HIncKKDbS2x/l1A/Gb6pcfI7q5tlKQjCdzNCT3N4k+7tbrzymTAS1Zsaud8FHo4c/U11A1UWQyB3CYLSRABio1yxxPF0XdbWwoLxXoURaXNBBQCXR5lGdBt8hugsuNWjDq2mzNMhJYPs13jJpcHj96xSQPKCuvqyal8IojhkPMAJrwLdcgXvTSDTbVVmbpfJK4UXeH1YNPa12bFqRDYf31hwx9YS6x9YB"; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentFrontImageSource = null; ImageSource fullDocumentBackImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (blinkidRecognizer.Result.ResultState == RecognizerResultState.Valid) { var blinkidResult = blinkidRecognizer.Result; stringResult = "BlinkID recognizer result:\n" + "FirstName: " + blinkidResult.FirstName + "\n" + "LastName: " + blinkidResult.LastName + "\n" + "Address: " + blinkidResult.Address + "\n" + "DocumentNumber: " + blinkidResult.DocumentNumber + "\n" + "Sex: " + blinkidResult.Sex + "\n"; var dob = blinkidResult.DateOfBirth; if (dob != null) { stringResult += "DateOfBirth: " + dob.Day + "." + dob.Month + "." + dob.Year + ".\n"; } var doi = blinkidResult.DateOfIssue; if (doi != null) { stringResult += "DateOfIssue: " + doi.Day + "." + doi.Month + "." + doi.Year + ".\n"; } var doe = blinkidResult.DateOfExpiry; if (doe != null) { stringResult += "DateOfExpiry: " + doe.Day + "." + doe.Month + "." + doe.Year + ".\n"; } // there are other fields to extract fullDocumentFrontImageSource = blinkidResult.FullDocumentFrontImage; fullDocumentBackImageSource = blinkidResult.FullDocumentBackImage; } // similarly, we can check for results of other recognizers //if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) //{ // var result = usdlRecognizer.Result; // stringResult = // "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + // "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + // "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + // "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + // "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + // "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + // "Height: " + result.GetField(UsdlKeys.Height) + "\n" + // "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + // "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + // "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + // "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // // License information // "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + // "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + // "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + // "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + // "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + // "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + // "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + // "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); // successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; //} } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentFrontImage.Source = fullDocumentFrontImageSource; fullDocumentBackImage.Source = fullDocumentBackImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAwCB68F5GmyjOoTBeIV5sKcvJJBquml9J7/y9U/vJu4mzhLUXs1iRDyIO2u+oQPeM9hSt+FmDxgVgj8ajVU9dHSlyINcsnrj27p75PHrFGCK0dMVnKzWDEjIZUcQfphQ8z8L4+ovU2x9LkQpCU44RxQi6aL8wFvotax8Xeq/Q8fuEK5wkVFQ6SInQnvjBrMaTP2Z+6o4ZMcpkdqq0BYeCKi4XArDIQn/lEOLm8WwpNYSt"; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4mAhH4ywlU8/Y6+eF1yoJj1Zazxmto8UxOc1IuQn/4Mvhg/nYz3rwYyhvNGBj94j9qaGGaQt0vlE4+wLdr4TSE8kcv2chQQpqjanzq+kDyo6P2Of+3JXcCRh/Cb+G75ADO3b3xm58r+eOS8nf3bN3sKgYH9maZMKhq8EGwW7HG6WPQNSXGOWYy9hrwcBCRrlEsXNDM/EfhPZGJjFXpwlD/fr8dl5ZFqSbo7lD7eXk2SBSqka3GBu7zbc"; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; stringResult = "PrimaryID: " + result.MrzResult.PrimaryId + "\n" + "SecondaryID: " + result.MrzResult.SecondaryId + "\n" + "Nationality: " + result.MrzResult.Nationality + "\n" + "Gender: " + result.MrzResult.Gender + "\n" + "Date of birth: " + result.MrzResult.DateOfBirth.Day + "." + result.MrzResult.DateOfBirth.Month + "." + result.MrzResult.DateOfBirth.Year + "."; fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; } // similarly, we can check for results of other recognizers if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = usdlRecognizer.Result; stringResult = "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + "Height: " + result.GetField(UsdlKeys.Height) + "\n" + "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // License information "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; } if (eudlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = eudlRecognizer.Result; stringResult = "First name: " + result.FirstName + "\n" + "Last name: " + result.LastName + "\n" + "Address: " + result.Address + "\n" + "Personal number: " + result.PersonalNumber + "\n" + "Driver number: " + result.DriverNumber; successFrameImageSource = eudlSuccessFrameGrabberRecognizer.Result.SuccessFrame; faceImageSource = result.FaceImage; fullDocumentImageSource = result.FullDocumentImage; } } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentImage.Source = fullDocumentImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FcAxRB59KP5uKHx3yK5i71SaHBhxP57cZUJAlNPBDUgzhrOUQdf7HIZk5yAOu2VV3dhk9+ZC9/rCR+Ob2psUpvm7GwgguVcn6byvrscHvxIjTisV1GyZ+Zhr5kjGhLvlToSWQ8kFkm+IVEmMXAJ/JWnHt8DESn0KTenlhpMKjhoPr5pAxOGLVSgqhoigoIOwmXwoL+e6SxfdH+yEQqsoSdVaTuIaojpMcmCtPDg2bHBZfot2QfDzEE="; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4mAhH4ywlU+/Zv8cEFJpkZtmqlysrWqktGZQ//Gs2MfTBoDAn5ug+aVBeaGW1fZbtks5QPvB0GHCyGe3ifl5FszmWiUzgJVOHuQ5I1P+81ya5Th79vsb6uIfy+tdcZDfEeNUX7ql0Bffa9UU9CgaJYIDIK9xHQPew3WbhQVvjbztHOuYhMtyo7NGCeLPc3zfbX3gkb3+wy9UzBVTeBb/VEyDgjvX4vn8ZlhBKH1NFUCXbDnTDhb9eh5/Utu19HQ="; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; stringResult = "PrimaryID: " + result.MrzResult.PrimaryId + "\n" + "SecondaryID: " + result.MrzResult.SecondaryId + "\n" + "Nationality: " + result.MrzResult.Nationality + "\n" + "Gender: " + result.MrzResult.Gender + "\n" + "Date of birth: " + result.MrzResult.DateOfBirth.Day + "." + result.MrzResult.DateOfBirth.Month + "." + result.MrzResult.DateOfBirth.Year + "."; fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; } // similarly, we can check for results of other recognizers if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = usdlRecognizer.Result; stringResult = "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + "Height: " + result.GetField(UsdlKeys.Height) + "\n" + "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // License information "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; } if (eudlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = eudlRecognizer.Result; stringResult = "First name: " + result.FirstName + "\n" + "Last name: " + result.LastName + "\n" + "Address: " + result.Address + "\n" + "Personal number: " + result.PersonalNumber + "\n" + "Driver number: " + result.DriverNumber; successFrameImageSource = eudlSuccessFrameGrabberRecognizer.Result.SuccessFrame; faceImageSource = result.FaceImage; fullDocumentImageSource = result.FullDocumentImage; } } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentImage.Source = fullDocumentImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
/// <summary> /// USDL recognizer will be used for scanning barcode from back side of United States' driver's licenses. /// </summary> //IUsdlRecognizer usdlRecognizer; /// <summary> /// This success frame grabber recognizer will wrap usdlRecognizer and will contain camera frame of the moment /// when wrapped recognizer finished its recognition. /// </summary> //ISuccessFrameGrabberRecognizer usdlSuccessFrameGrabberRecognizer; public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.sample if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEVY29tLm1pY3JvYmxpbmsuc2FtcGxl1BIcP+dpSuS/38JVP6aKNaBKXyOa0lx8FMppKnmLvzN4FxHDuhb/iU7ojs9ZV2HHMGkgO+lMeHXvwTM9jNX3cTyExpXVaxJ06Ki8O5II97dgREuRvs8ZoV7qGSMhZtLe9b4wPe69vbvgkmGrUPLzNGJX8uxTtpRgLOtFSpNXshQZ/nnRhxi/F2d9sY7sYI1jTYAMoacu0AWrciTcSFTYe57lLkTFH6wtJTmGzzPF18NqhltfO7+5Bwk5/9AQ9blIOOBFr5s="; } else { licenseKey = "sRwAAAAVY29tLm1pY3JvYmxpbmsuc2FtcGxlU9kJdf5ZkGlTu9U3P8tqz/OQlP4WPMiRjJ8ogPx3I/XahwQ+FZH+4q0sbbRGfo1IDXwYR6Cdy7o6IZeOzT2iRIZT7eW+Cqk65y1ngxGxk5caaR7WSyCGCe/yQqSjp1fxerQaVWUL0uK7s0xfv8EtVTqz7hocOKoqeC4c2m0L+WeEc7kAHGuYjoIMVm2BOmEtCOR4grLQUmrz5ojA8fFjuknxBnEGkFWdJNT0evkrH/BgcnM9S+CH2018twWbYYV8ggqaD8DB"; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentFrontImageSource = null; ImageSource fullDocumentBackImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (blinkidRecognizer.Result.ResultState == RecognizerResultState.Valid) { var blinkidResult = blinkidRecognizer.Result; stringResult = "BlinkID recognizer result:\n" + BuildResult(blinkidResult.FirstName, "First name") + BuildResult(blinkidResult.LastName, "Last name") + BuildResult(blinkidResult.FullName, "Full name") + BuildResult(blinkidResult.LocalizedName, "Localized name") + BuildResult(blinkidResult.AdditionalNameInformation, "Additional name info") + BuildResult(blinkidResult.Address, "Address") + BuildResult(blinkidResult.AdditionalAddressInformation, "Additional address info") + BuildResult(blinkidResult.DocumentNumber, "Document number") + BuildResult(blinkidResult.DocumentAdditionalNumber, "Additional document number") + BuildResult(blinkidResult.Sex, "Sex") + BuildResult(blinkidResult.IssuingAuthority, "Issuing authority") + BuildResult(blinkidResult.Nationality, "Nationality") + BuildResult(blinkidResult.DateOfBirth, "DateOfBirth") + BuildResult(blinkidResult.Age, "Age") + BuildResult(blinkidResult.DateOfIssue, "Date of issue") + BuildResult(blinkidResult.DateOfExpiry, "Date of expiry") + BuildResult(blinkidResult.DateOfExpiryPermanent, "Date of expiry permanent") + BuildResult(blinkidResult.MaritalStatus, "Martial status") + BuildResult(blinkidResult.PersonalIdNumber, "Personal Id Number") + BuildResult(blinkidResult.Profession, "Profession") + BuildResult(blinkidResult.Race, "Race") + BuildResult(blinkidResult.Religion, "Religion") + BuildResult(blinkidResult.ResidentialStatus, "Residential Status"); IDriverLicenseDetailedInfo licenceInfo = blinkidResult.DriverLicenseDetailedInfo; if (licenceInfo != null) { stringResult += BuildResult(licenceInfo.Restrictions, "Restrictions") + BuildResult(licenceInfo.Endorsements, "Endorsements") + BuildResult(licenceInfo.VehicleClass, "Vehicle class") + BuildResult(licenceInfo.Conditions, "Conditions"); } fullDocumentFrontImageSource = blinkidResult.FullDocumentFrontImage; fullDocumentBackImageSource = blinkidResult.FullDocumentBackImage; } // similarly, we can check for results of other recognizers //if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) //{ // var result = usdlRecognizer.Result; // stringResult = // "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + // "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + // "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + // "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + // "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + // "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + // "Height: " + result.GetField(UsdlKeys.Height) + "\n" + // "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + // "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + // "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + // "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // // License information // "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + // "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + // "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + // "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + // "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + // "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + // "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + // "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); // successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; //} } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentFrontImage.Source = fullDocumentFrontImageSource; fullDocumentBackImage.Source = fullDocumentBackImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }
private void InitBlinkID() { // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { //licenseKey = @"sRwAAAEQY29tLmNobWwuaXQuY2Nmc0iUtoUk/ef1YJ5jX+o5uIzyxuRON+o5AprGt1y0HRXyOS3r7Xn/J8u2qeYccWpDTk0d8mdaDPrcaJjP7EUTBVG7BwPOlZfYAd4bPftj+19de9RS9WPc8U+nSNUgG39oaeL7cG4/J8B6V13gvRYYCDRAQh8EUDUy7R77C7WcuFQ4UMs2c7MkJxwFuxtX0k2W5TvMANrFRd31HhWVGYl8v1QsBgD2qxPBDq1QIXNdmmfHd0PCavSzTUVXE0tuTGjm7ZiY"; licenseKey = @"sRwAAAETY29tLmNobWwuaXQuY2hlY2tpbgGm5r7k3Ek2zECA87ExzLf1KJZaW29XBS/9dg+G7MK6iq76H9mvl6iZWyFCQIZkJDJtfeI4Ojyvaa33CV/GUaGfjAeT/gbPdEECFLJdiJzYEAFGXlwFYpkfb4wDuHefL7y+R4dJFOdoCKFTG78XSRWoeIMReXDXzayIXHmSn09Fw9fzpkcM3eDNmtxnza4a6M07yoU="; } else { //licenseKey = "sRwAAAEQY29tLmNobWwuaXQuY2Nmc0iUtoUk/ef1YJ5jX+o5uIzyxuRON+o5AprGt1y0HRXyOS3r7Xn/J8u2qeYccWpDTk0d8mdaDPrcaJjP7EUTBVG7BwPOlZfYAd4bPftj+19de9RS9WPc8U+nSNUgG39oaeL7cG4/J8B6V13gvRYYCDRAQh8EUDUy7R77C7WcuFQ4UMs2c7MkJxwFuxtX0k2W5TvMANrFRd31HhWVGYl8v1QsBgD2qxPBDq1QIXNdmmfHd0PCavSzTUVXE0tuTGjm7ZiY"; licenseKey = "sRwAAAATY29tLmNobWwuaXQuY2hlY2tpbtRm4Sqvhw507E+XVCNTtcxAXSpC2KKosWxzcIjD++kxxsJIOUU4a8rhxtQ3g30tGeoYbJOCycdV/DSfLEmiz1E2g4PgA53THm1J2IyLsczXEmhqqAAEO3wmKSIwi2jgO8MHZvu35bDgH9/EV34AuKVxE97kdVh4LIIxmbaOcJFMzH9syNrE8Qfano3mAP8O4zxg0/c="; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <ScanningDoneMessage>(this, ScanningDoneMessageId, async(sender) => { pageLoading(); try { ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; lname = result.MrzResult.PrimaryId; fname = result.MrzResult.SecondaryId; nationality = result.MrzResult.Nationality; gender = result.MrzResult.Gender; PassportNumber = Regex.Replace(result.MrzResult.DocumentNumber, "[^A-Za-z0-9 _]", ""); dateOfExpiry = $"{result.MrzResult.DateOfExpiry.Day}-{result.MrzResult.DateOfExpiry.Month}-{result.MrzResult.DateOfExpiry.Year}"; dateOfBirthPass = $"{result.MrzResult.DateOfBirth.Day}-{result.MrzResult.DateOfBirth.Month}-{result.MrzResult.DateOfBirth.Year}"; //List of identification methods from dictionary var nameToAlpha2FromAlpha3 = CountryDictionary.listAlpha3To(); //Getting Key Value from Dictoinary by passing the THREE Letter code nationality = nameToAlpha2FromAlpha3.FirstOrDefault(x => x.Key == nationality).Value; //Extracting document Images fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; //Set Image to Globals Constants.PassportCopy = fullDocumentImageSource; await existingGuestDetailsFromDatabses(2, PassportNumber); Device.BeginInvokeOnMainThread(() => { GuestFisrtName.Text = fname; GuestLastName.Text = lname; guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); PassportExpiry.Date = DateTime.ParseExact(dateOfExpiry, "d-M-yyyy", CultureInfo.CurrentCulture); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); DateOfBirth.Date = DateTime.ParseExact(dateOfBirthPass, "d-M-yyyy", CultureInfo.CurrentCulture); stopPageLoading(); }); } } } catch (Exception) { Device.BeginInvokeOnMainThread(() => { stopPageLoading(); guestEntryDetails(guestNumber.Text, PassportNumber, fname, lname, "", "", "", "", ""); guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); guestSalutationPicker(""); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); PassportExpiry.Date = DateTime.ParseExact(dateOfExpiry, "d-M-yyyy", CultureInfo.CurrentCulture); DateOfBirth.Date = DateTime.ParseExact(dateOfBirthPass, "d-M-yyyy", CultureInfo.CurrentCulture); Visitperhotel = "00"; Totalvisit = "00"; RevenueTotal = "0.00"; RevenueRoom = "0.00"; RevenueFnb = "0.00"; RevenueOther = "0.00"; stopPageLoading(); DisplayAlert(Constants._headerMessage, Constants._noDetails, Constants._buttonOkay); }); } }); }
public BlinkIDPage() { InitializeComponent(); // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.RuntimePlatform == Device.iOS) { licenseKey = "sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDF2B9jpa6FeAxSjaWUg1ROYBfuTUj5ciQyp9KpRtdClsjclAqYTT1BA7QMj6tUv6yIwdGZNSUhiR253O9Zugyv6tsc8hB9XvpMvDAHOiAmgzkj5SacPTjp5C4xZwKCmER2NUf4YSDddznrI7btd5cNnr0Bc5lT0wNHzlN7Z6r04dqoI+jzrCW65IgF8DrA/t4C6O0/lxthm+IfAmobL0kfI0ui6/fy3m8OZ31AacLKO1qb4T0A=="; } else { licenseKey = "sRwAAAAeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lke7qv4oIhH4ywlU8/Zqc2tpXY3x6Jq4MYktFtYaRbzI3x0Qxrr0NeFEjL6qt8Qcz144x2F5LGg1bHXgkRXbt37saoFv1HJUiJ50Y4YHglH8SqhyfSzsT/C/vQEAKXgZBQuNeeCTY6RttMciEbHHHj7nybEz9+aOoBXfx0+XXx3cU4L6Wbmf/5EAXokQXtEkL3mCR8VC/51ohQVyRIgItohusasIcfe8B+UjUMCZU9v1B0bvHcUKZH6g=="; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // license keys must be set before creating Recognizer, othervise InvalidLicenseKeyException will be thrown // the following code creates and sets up implementation of MrtdRecognizer mrtdRecognizer = DependencyService.Get <IMrtdRecognizer>(); mrtdRecognizer.ReturnFullDocumentImage = true; // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations mrtdSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(mrtdRecognizer); // the following code creates and sets up implementation of UsdlRecognizer usdlRecognizer = DependencyService.Get <IUsdlRecognizer>(); // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations usdlSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(usdlRecognizer); // the following code creates and sets up implementation of EudlRecognizer eudlRecognizer = DependencyService.Get <IEudlRecognizer>(); eudlRecognizer.ReturnFaceImage = true; eudlRecognizer.ReturnFullDocumentImage = true; // success frame grabber recognizer must be constructed with reference to its slave recognizer, // so we need to use factory to avoid DependencyService's limitations eudlSuccessFrameGrabberRecognizer = DependencyService.Get <ISuccessFrameGrabberRecognizerFactory>().CreateSuccessFrameGrabberRecognizer(eudlRecognizer); // subscribe to scanning done message MessagingCenter.Subscribe <Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => { ImageSource faceImageSource = null; ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; stringResult = "PrimaryID: " + result.MrzResult.PrimaryId + "\n" + "SecondaryID: " + result.MrzResult.SecondaryId + "\n" + "Nationality: " + result.MrzResult.Nationality + "\n" + "Gender: " + result.MrzResult.Gender + "\n" + "Date of birth: " + result.MrzResult.DateOfBirth.Day + "." + result.MrzResult.DateOfBirth.Month + "." + result.MrzResult.DateOfBirth.Year + "."; fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; } // similarly, we can check for results of other recognizers if (usdlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = usdlRecognizer.Result; stringResult = "USDL version: " + result.GetField(UsdlKeys.StandardVersionNumber) + "\n" + "Family name: " + result.GetField(UsdlKeys.CustomerFamilyName) + "\n" + "First name: " + result.GetField(UsdlKeys.CustomerFirstName) + "\n" + "Date of birth: " + result.GetField(UsdlKeys.DateOfBirth) + "\n" + "Sex: " + result.GetField(UsdlKeys.Sex) + "\n" + "Eye color: " + result.GetField(UsdlKeys.EyeColor) + "\n" + "Height: " + result.GetField(UsdlKeys.Height) + "\n" + "Street: " + result.GetField(UsdlKeys.AddressStreet) + "\n" + "City: " + result.GetField(UsdlKeys.AddressCity) + "\n" + "Jurisdiction: " + result.GetField(UsdlKeys.AddressJurisdictionCode) + "\n" + "Postal code: " + result.GetField(UsdlKeys.AddressPostalCode) + "\n" + // License information "Issue date: " + result.GetField(UsdlKeys.DocumentIssueDate) + "\n" + "Expiration date: " + result.GetField(UsdlKeys.DocumentExpirationDate) + "\n" + "Issuer ID: " + result.GetField(UsdlKeys.IssuerIdentificationNumber) + "\n" + "Jurisdiction version: " + result.GetField(UsdlKeys.JurisdictionVersionNumber) + "\n" + "Vehicle class: " + result.GetField(UsdlKeys.JurisdictionVehicleClass) + "\n" + "Restrictions: " + result.GetField(UsdlKeys.JurisdictionRestrictionCodes) + "\n" + "Endorsments: " + result.GetField(UsdlKeys.JurisdictionEndorsementCodes) + "\n" + "Customer ID: " + result.GetField(UsdlKeys.CustomerIdNumber); successFrameImageSource = usdlSuccessFrameGrabberRecognizer.Result.SuccessFrame; } if (eudlRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = eudlRecognizer.Result; stringResult = "First name: " + result.FirstName + "\n" + "Last name: " + result.LastName + "\n" + "Address: " + result.Address + "\n" + "Personal number: " + result.PersonalNumber + "\n" + "Driver number: " + result.DriverNumber; successFrameImageSource = eudlSuccessFrameGrabberRecognizer.Result.SuccessFrame; faceImageSource = result.FaceImage; fullDocumentImageSource = result.FullDocumentImage; } } // updating the UI must be performed on main thread Device.BeginInvokeOnMainThread(() => { resultsEditor.Text = stringResult; fullDocumentImage.Source = fullDocumentImageSource; successScanImage.Source = successFrameImageSource; faceImage.Source = faceImageSource; }); }); }