From e4bf8f23480b6b8b250b684c96c3c9fc658d4f38 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 11:18:04 +0100 Subject: [PATCH 01/18] Renamed mykad to mykad front and added mykad back recognizer --- www/js/index.js | 14 ++++++++++++-- www/js/mykad_keys.js | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/www/js/index.js b/www/js/index.js index 0ae2aea..86dd0da 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -70,7 +70,8 @@ var app = { * EUDL - scans the front side of European driver's license * UKDL - scans the front side of United Kingom driver's license * DEDL - scans the front side of German driver's license - * MyKad - scans the front side of Malaysian ID card + * MyKadFront - scans the front side of Malaysian ID card + * MyKadBack - scans the back side of Malaysian ID card * GermanOldID - scans the front side of old German ID card * GermanIDFront - scans the front side of German ID card * GermanIDBack - scans the back side of German ID card @@ -216,7 +217,7 @@ var app = { "First name: " + fields[kPPeudlFirstName] + "
" + "Last name: " + fields[kPPeudlLastName] + "
"; - } else if (recognizerResult.resultType == "MyKad result") { + } else if (recognizerResult.resultType == "MyKadFront result") { resultDiv.innerHTML = /** Personal information */ "ID Type: " + fields[kPPDataType] + "
" + @@ -231,6 +232,15 @@ var app = { "Religion: " + fields[kPPmyKadReligion] + "
" + "Sex: " + fields[kPPmyKadSex] + "
"; + } else if (recognizerResult.resultType == "MyKadBack result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "NRIC Number: " + fields[kPPmyKadNricNumber] + "
" + + "Extended NRIC Number: " + fields[kPPmyKadBackExtendedNricNumber] + "
" + + "Birth Date: " + fields[kPPmyKadBackBirthDate] + "
" + + "Sex: " + fields[kPPmyKadBackSex] + "
"; + } else if (recognizerResult.resultType == "GermanOldID result") { resultDiv.innerHTML = /** Personal information */ diff --git a/www/js/mykad_keys.js b/www/js/mykad_keys.js index 3422f69..b6cd070 100644 --- a/www/js/mykad_keys.js +++ b/www/js/mykad_keys.js @@ -39,3 +39,15 @@ var kPPmyKadReligion = "ownerReligion"; var kPPmyKadSex = "ownerSex"; + + +var kPPmyKadBackNricNumber = "MyKadExtendedNRIC.NRIC"; + + +var kPPmyKadBackExtendedNricNumber = "MyKadExtendedNRIC.ExtendedNRIC"; + + +var kPPmyKadBackBirthDate = "MyKadExtendedNRIC.DateOfBirth"; + + +var kPPmyKadBackSex = "MyKadExtendedNRIC.Sex"; From 5b934d51c114922d89bdae9955f5aadbadff5156 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:21:06 +0100 Subject: [PATCH 02/18] [ios] Renamed MyKad to MyKadFront and added MyKadBack recognizer --- BlinkID/src/ios/sources/CDVBlinkIdScanner.m | 94 +++++++++++++++++---- 1 file changed, 76 insertions(+), 18 deletions(-) diff --git a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m index dbc1d0b..b916b9d 100644 --- a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m +++ b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m @@ -29,7 +29,8 @@ const NSString *UKDL_TYPE = @"UKDL"; const NSString *DEDL_TYPE = @"DEDL"; const NSString *EUDL_TYPE = @"EUDL"; -const NSString *MYKAD_TYPE = @"MyKad"; +const NSString *MYKAD_FRONT_TYPE = @"MyKadFront"; +const NSString *MYKAD_BACK_TYPE = @"MyKadBack"; const NSString *GERMAN_OLD_ID_TYPE = @"GermanOldID"; const NSString *GERMAN_ID_FRONT_TYPE = @"GermanIDFront"; const NSString *GERMAN_ID_BACK_TYPE = @"GermanIDBack"; @@ -60,7 +61,8 @@ NSString *UKDL_RESULT_TYPE = @"UKDL result"; NSString *DEDL_RESULT_TYPE = @"DEDL result"; NSString *EUDL_RESULT_TYPE = @"EUDL result"; -NSString *MYKAD_RESULT_TYPE = @"MyKad result"; +NSString *MYKAD_FRONT_RESULT_TYPE = @"MyKadFront result"; +NSString *MYKAD_BACK_RESULT_TYPE = @"MyKadBack result"; NSString *BARCODE_RESULT_TYPE = @"Barcode result"; NSString *GERMAN_OLD_ID_RESULT_TYPE = @"GermanOldID result"; NSString *GERMAN_ID_FRONT_RESULT_TYPE = @"GermanFrontID result"; @@ -88,7 +90,8 @@ // Card specific keys NSString * MRTD_DATE_OF_BIRTH = @"DateOfBirth"; NSString * MRTD_DATE_OF_EXPIRY = @"DateOfExpiry"; -NSString * MYKAD_OWNER_BIRTH_DATE = @"ownerBirthDate"; +NSString * MYKAD_FRONT_OWNER_BIRTH_DATE = @"ownerBirthDate"; +NSString * MYKAD_BACK_OWNER_BIRTH_DATE = @"MyKadExtendedNRIC.DateOfBirth"; NSString * GERMAN_ID_DATE_OF_ISSUE = @"DeIDDateOfIssue.DateOfIssue"; NSString * GERMAN_PASS_DATE_OF_ISSUE = @"GermanPassportDateOfIssue.DateOfIssue"; NSString * SINGAPORE_DATE_OF_BIRTH = @"SingaporeIDDOBSex.DateOfBirth"; @@ -355,14 +358,14 @@ - (PPDocumentFaceRecognizerSettings *)documentFaceRecognizerSettings { return documentFaceReconizerSettings; } -- (PPMyKadFrontRecognizerSettings *)myKadRecognizerSettings { +- (PPMyKadFrontRecognizerSettings *)myKadFrontRecognizerSettings { - PPMyKadFrontRecognizerSettings *myKadRecognizerSettings = [[PPMyKadFrontRecognizerSettings alloc] init]; + PPMyKadFrontRecognizerSettings *myKadFrontRecognizerSettings = [[PPMyKadFrontRecognizerSettings alloc] init]; // Setup returning document image if ([self shouldReturnDocumentImage]) { - myKadRecognizerSettings.showFullDocument = YES; + myKadFrontRecognizerSettings.showFullDocument = YES; NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPMyKadFrontRecognizerResult class]]; [dict setObject:[NSNull null] forKey:@(PPImageTypeDocument)]; @@ -371,13 +374,31 @@ - (PPMyKadFrontRecognizerSettings *)myKadRecognizerSettings { // Setup returning face image if ([self shouldReturnFaceImage]) { - myKadRecognizerSettings.showFaceImage = YES; + myKadFrontRecognizerSettings.showFaceImage = YES; NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPMyKadFrontRecognizerResult class]]; [dict setObject:[NSNull null] forKey:@(PPImageTypeFace)]; } - return myKadRecognizerSettings; + return myKadFrontRecognizerSettings; +} + +- (PPMyKadBackRecognizerSettings *)myKadBackRecognizerSettings { + + PPMyKadBackRecognizerSettings *myKadBackRecognizerSettings = [[PPMyKadBackRecognizerSettings alloc] init]; + + // Setup returning document image + + if ([self shouldReturnDocumentImage]) { + myKadBackRecognizerSettings.displayFullDocumentImage = YES; + + NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPMyKadBackRecognizerResult class]]; + [dict setObject:[NSNull null] forKey:@(PPImageTypeDocument)]; + } + + return myKadBackRecognizerSettings; +} + } - (PPGermanOldIDRecognizerSettings *)germanOldIDRecognizerSettings { @@ -603,8 +624,14 @@ - (BOOL)shouldUseDocumentFaceRecognizerForTypes:(NSArray *)types { return [types containsObject:DOCUMENTFACE_TYPE]; } -- (BOOL)shouldUseMyKadRecognizerForTypes:(NSArray *)types { - return [types containsObject:MYKAD_TYPE]; +- (BOOL)shouldUseMyKadFrontRecognizerForTypes:(NSArray *)types { + return [types containsObject:MYKAD_FRONT_TYPE]; +} + +- (BOOL)shouldUseMyKadBackRecognizerForTypes:(NSArray *)types { + return [types containsObject:MYKAD_BACK_TYPE]; +} + } - (BOOL)shouldUseGermanOldIDType:(NSArray *)types { @@ -729,8 +756,14 @@ - (PPCameraCoordinator *)coordinatorWithError:(NSError **)error { [settings.scanSettings addRecognizerSettings:[self documentFaceRecognizerSettings]]; } - if ([self shouldUseMyKadRecognizerForTypes:types]) { - [settings.scanSettings addRecognizerSettings:[self myKadRecognizerSettings]]; + if ([self shouldUseMyKadFrontRecognizerForTypes:types]) { + [settings.scanSettings addRecognizerSettings:[self myKadFrontRecognizerSettings]]; + } + + if ([self shouldUseMyKadBackRecognizerForTypes:types]) { + [settings.scanSettings addRecognizerSettings:[self myKadBackRecognizerSettings]]; + } + } if ([self shouldUseGermanOldIDType:types]) { @@ -862,9 +895,22 @@ - (void)setDictionary:(NSMutableDictionary *)dict withEudlRecognizerResult:(PPEu [self setupDictionary:dict withImagesForResult:eudlResult]; } -- (void)setDictionary:(NSMutableDictionary *)dict withMyKadRecognizerResult:(PPMyKadFrontRecognizerResult *)myKadResult { - NSMutableDictionary *stringElements = [NSMutableDictionary dictionaryWithDictionary:[myKadResult getAllStringElements]]; - [stringElements setObject:[myKadResult rawOwnerBirthDate] forKey:MYKAD_OWNER_BIRTH_DATE]; +- (void)setDictionary:(NSMutableDictionary *)dict withMyKadFrontRecognizerResult:(PPMyKadFrontRecognizerResult *)myKadFrontResult { + NSMutableDictionary *stringElements = [NSMutableDictionary dictionaryWithDictionary:[myKadFrontResult getAllStringElements]]; + [stringElements setObject:[myKadFrontResult rawOwnerBirthDate] forKey:MYKAD_FRONT_OWNER_BIRTH_DATE]; + [dict setObject:stringElements forKey:FIELDS]; + [dict setObject:MYKAD_FRONT_RESULT_TYPE forKey:RESULT_TYPE]; + [self setupDictionary:dict withImagesForResult:myKadFrontResult]; +} + +- (void)setDictionary:(NSMutableDictionary *)dict withMyKadBackRecognizerResult:(PPMyKadBackRecognizerResult *)myKadBackResult { + NSMutableDictionary *stringElements = [NSMutableDictionary dictionaryWithDictionary:[myKadBackResult getAllStringElements]]; + [stringElements setObject:[myKadBackResult rawOwnerBirthDate] forKey:MYKAD_BACK_OWNER_BIRTH_DATE]; + [dict setObject:stringElements forKey:FIELDS]; + [dict setObject:MYKAD_BACK_RESULT_TYPE forKey:RESULT_TYPE]; + [self setupDictionary:dict withImagesForResult:myKadBackResult]; +} + [dict setObject:stringElements forKey:FIELDS]; [dict setObject:MYKAD_RESULT_TYPE forKey:RESULT_TYPE]; [self setupDictionary:dict withImagesForResult:myKadResult]; @@ -1049,14 +1095,25 @@ - (void)returnResults:(NSArray *)results cancelled:(BOOL)cancelled { } if ([result isKindOfClass:[PPMyKadFrontRecognizerResult class]]) { - PPMyKadFrontRecognizerResult *myKadDecoderResult = (PPMyKadFrontRecognizerResult *)result; + PPMyKadFrontRecognizerResult *myKadFrontDecoderResult = (PPMyKadFrontRecognizerResult *)result; NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; - [self setDictionary:dict withMyKadRecognizerResult:myKadDecoderResult]; + [self setDictionary:dict withMyKadFrontRecognizerResult:myKadFrontDecoderResult]; [resultArray addObject:dict]; + continue; + } + + if ([result isKindOfClass:[PPMyKadBackRecognizerResult class]]) { + PPMyKadBackRecognizerResult *myKadBackDecoderResult = (PPMyKadBackRecognizerResult *)result; + + NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; + [self setDictionary:dict withMyKadBackRecognizerResult:myKadBackDecoderResult]; + + [resultArray addObject:dict]; + continue; } - + if ([result isKindOfClass:[PPUnitedArabEmiratesIDBackRecognizerResult class]]) { PPUnitedArabEmiratesIDBackRecognizerResult *uaeIDBackResult = (PPUnitedArabEmiratesIDBackRecognizerResult *)result; @@ -1242,6 +1299,7 @@ - (void)scanningViewController:(UIViewController *)sca [self setImageMetadata:imageMetadata forName:[PPMrtdRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMrtdRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPDocumentFaceRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPDocumentFaceRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadFrontRecognizerResult class]]; + [self setImageMetadata:imageMetadata forName:[PPMyKadBackRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadBackRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPEudlRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPEudlRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanOldIDRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanOldIDRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanIDFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanIDFrontRecognizerResult class]]; From 3ef0c4220c4e9725e5aa1b14a00d51199022f6bd Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:52:29 +0100 Subject: [PATCH 03/18] Added mytentera recognizer --- www/index.html | 1 + www/js/index.js | 17 ++++++++++++++++ www/js/mytentera_keys.js | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 www/js/mytentera_keys.js diff --git a/www/index.html b/www/index.html index a0d7b2c..ff31c58 100644 --- a/www/index.html +++ b/www/index.html @@ -48,6 +48,7 @@

Demo App

+ diff --git a/www/js/index.js b/www/js/index.js index 86dd0da..3b152f0 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -72,6 +72,7 @@ var app = { * DEDL - scans the front side of German driver's license * MyKadFront - scans the front side of Malaysian ID card * MyKadBack - scans the back side of Malaysian ID card + * MyTentera - scans the front side of Malaysian Tentera card * GermanOldID - scans the front side of old German ID card * GermanIDFront - scans the front side of German ID card * GermanIDBack - scans the back side of German ID card @@ -241,6 +242,22 @@ var app = { "Birth Date: " + fields[kPPmyKadBackBirthDate] + "
" + "Sex: " + fields[kPPmyKadBackSex] + "
"; + } else if (recognizerResult.resultType == "MyTentera result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "Army Number: " + fields[kPPmyTenteraArmyNumber] + "
" + + "NRIC Number: " + fields[kPPmyTenteraNricNumber] + "
" + + "Address: " + fields[kPPmyTenteraAddress] + "
" + + "Address ZIP Code: " + fields[kPPmyTenteraAddressZipCode] + "
" + + "Address Street: " + fields[kPPmyTenteraAddressStreet] + "
" + + "Address City: " + fields[kPPmyTenteraAddressCity] + "
" + + "Address State: " + fields[kPPmyTenteraAddressState] + "
" + + "Birth Date: " + fields[kPPmyTenteraBirthDate] + "
" + + "Full Name: " + fields[kPPmyTenteraFullName] + "
" + + "Religion: " + fields[kPPmyTenteraReligion] + "
" + + "Sex: " + fields[kPPmyTenteraSex] + "
"; + } else if (recognizerResult.resultType == "GermanOldID result") { resultDiv.innerHTML = /** Personal information */ diff --git a/www/js/mytentera_keys.js b/www/js/mytentera_keys.js new file mode 100644 index 0000000..4438c50 --- /dev/null +++ b/www/js/mytentera_keys.js @@ -0,0 +1,44 @@ +// +// mytentera_keys.js +// MicroBlink BlinkID library +// +// Copyright (c) 2015 MicroBlink. All rights reserved. +// + + +//pragma mark - Keys for obtaining data on Malaysian identity cards + +var kPPmyTenteraDataType = "PaymentDataType"; + + +var kPPmyTenteraArmyNumber = "MyTenteraArmyNumber.OwnerArmyNumber"; + + +var kPPmyTenteraNricNumber = "MyTenteraNricNumber.NricNumber"; + + +var kPPmyTenteraAddress = "MyTenteraAddress.OwnerFullAddress"; + + +var kPPmyTenteraAddressZipCode = "MyTenteraAddress.OwnerAddressZipCode"; + + +var kPPmyTenteraAddressStreet = "MyTenteraAddress.OwnerAddressStreet"; + + +var kPPmyTenteraAddressCity = "MyTenteraAddress.OwnerAddressCity"; + + +var kPPmyTenteraAddressState = "MyTenteraAddress.OwnerAddressState"; + + +var kPPmyTenteraBirthDate = "MyTenteraNricNumber.OwnerBirthDate"; + + +var kPPmyTenteraFullName = "MyTenteraOwnerFullName.OwnerFullName"; + + +var kPPmyTenteraReligion = "MyTenteraReligion.OwnerReligion"; + + +var kPPmyTenteraSex = "MyTenteraNricNumber.OwnerSex"; From c1f5be54be0fcd9b9e331729112e2707faba3952 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:55:20 +0100 Subject: [PATCH 04/18] [ios] Added mytentera recognizer --- BlinkID/src/ios/sources/CDVBlinkIdScanner.m | 49 ++++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m index b916b9d..aa2fb5d 100644 --- a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m +++ b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m @@ -31,6 +31,7 @@ const NSString *EUDL_TYPE = @"EUDL"; const NSString *MYKAD_FRONT_TYPE = @"MyKadFront"; const NSString *MYKAD_BACK_TYPE = @"MyKadBack"; +const NSString *MYTENTERA_TYPE = @"MyTentera"; const NSString *GERMAN_OLD_ID_TYPE = @"GermanOldID"; const NSString *GERMAN_ID_FRONT_TYPE = @"GermanIDFront"; const NSString *GERMAN_ID_BACK_TYPE = @"GermanIDBack"; @@ -63,6 +64,7 @@ NSString *EUDL_RESULT_TYPE = @"EUDL result"; NSString *MYKAD_FRONT_RESULT_TYPE = @"MyKadFront result"; NSString *MYKAD_BACK_RESULT_TYPE = @"MyKadBack result"; +NSString *MYTENTERA_RESULT_TYPE = @"MyTentera result"; NSString *BARCODE_RESULT_TYPE = @"Barcode result"; NSString *GERMAN_OLD_ID_RESULT_TYPE = @"GermanOldID result"; NSString *GERMAN_ID_FRONT_RESULT_TYPE = @"GermanFrontID result"; @@ -92,6 +94,7 @@ NSString * MRTD_DATE_OF_EXPIRY = @"DateOfExpiry"; NSString * MYKAD_FRONT_OWNER_BIRTH_DATE = @"ownerBirthDate"; NSString * MYKAD_BACK_OWNER_BIRTH_DATE = @"MyKadExtendedNRIC.DateOfBirth"; +NSString * MYTENTERA_OWNER_BIRTH_DATE = @"MyTenteraNricNumber.OwnerBirthDate"; NSString * GERMAN_ID_DATE_OF_ISSUE = @"DeIDDateOfIssue.DateOfIssue"; NSString * GERMAN_PASS_DATE_OF_ISSUE = @"GermanPassportDateOfIssue.DateOfIssue"; NSString * SINGAPORE_DATE_OF_BIRTH = @"SingaporeIDDOBSex.DateOfBirth"; @@ -399,6 +402,29 @@ - (PPMyKadBackRecognizerSettings *)myKadBackRecognizerSettings { return myKadBackRecognizerSettings; } +- (PPMyTenteraRecognizerSettings *)myTenteraRecognizerSettings { + + PPMyTenteraRecognizerSettings *myTenteraRecognizerSettings = [[PPMyTenteraRecognizerSettings alloc] init]; + + // Setup returning document image + + if ([self shouldReturnDocumentImage]) { + myTenteraRecognizerSettings.displayFullDocumentImage = YES; + + NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPMyTenteraRecognizerResult class]]; + [dict setObject:[NSNull null] forKey:@(PPImageTypeDocument)]; + } + + // Setup returning face image + + if ([self shouldReturnFaceImage]) { + myTenteraRecognizerSettings.displayFaceImage = YES; + + NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPMyTenteraRecognizerResult class]]; + [dict setObject:[NSNull null] forKey:@(PPImageTypeFace)]; + } + + return myTenteraRecognizerSettings; } - (PPGermanOldIDRecognizerSettings *)germanOldIDRecognizerSettings { @@ -632,6 +658,8 @@ - (BOOL)shouldUseMyKadBackRecognizerForTypes:(NSArray *)types { return [types containsObject:MYKAD_BACK_TYPE]; } +- (BOOL)shouldUseMyTenteraRecognizerForTypes:(NSArray *)types { + return [types containsObject:MYTENTERA_TYPE]; } - (BOOL)shouldUseGermanOldIDType:(NSArray *)types { @@ -764,6 +792,8 @@ - (PPCameraCoordinator *)coordinatorWithError:(NSError **)error { [settings.scanSettings addRecognizerSettings:[self myKadBackRecognizerSettings]]; } + if ([self shouldUseMyTenteraRecognizerForTypes:types]) { + [settings.scanSettings addRecognizerSettings:[self myTenteraRecognizerSettings]]; } if ([self shouldUseGermanOldIDType:types]) { @@ -911,9 +941,12 @@ - (void)setDictionary:(NSMutableDictionary *)dict withMyKadBackRecognizerResult: [self setupDictionary:dict withImagesForResult:myKadBackResult]; } +- (void)setDictionary:(NSMutableDictionary *)dict withMyTenteraRecognizerResult:(PPMyTenteraRecognizerResult *)myTenteraResult { + NSMutableDictionary *stringElements = [NSMutableDictionary dictionaryWithDictionary:[myTenteraResult getAllStringElements]]; + [stringElements setObject:[myTenteraResult rawOwnerBirthDate] forKey:MYTENTERA_OWNER_BIRTH_DATE]; [dict setObject:stringElements forKey:FIELDS]; - [dict setObject:MYKAD_RESULT_TYPE forKey:RESULT_TYPE]; - [self setupDictionary:dict withImagesForResult:myKadResult]; + [dict setObject:MYTENTERA_RESULT_TYPE forKey:RESULT_TYPE]; + [self setupDictionary:dict withImagesForResult:myTenteraResult]; } - (void)setDictionary:(NSMutableDictionary *)dict withDocumentDetectorResult:(PPDetectorRecognizerResult *)detectorRecognizerResult { @@ -1114,6 +1147,16 @@ - (void)returnResults:(NSArray *)results cancelled:(BOOL)cancelled { continue; } + if ([result isKindOfClass:[PPMyTenteraRecognizerResult class]]) { + PPMyTenteraRecognizerResult *myTenteraDecoderResult = (PPMyTenteraRecognizerResult *)result; + + NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; + [self setDictionary:dict withMyTenteraRecognizerResult:myTenteraDecoderResult]; + + [resultArray addObject:dict]; + continue; + } + if ([result isKindOfClass:[PPUnitedArabEmiratesIDBackRecognizerResult class]]) { PPUnitedArabEmiratesIDBackRecognizerResult *uaeIDBackResult = (PPUnitedArabEmiratesIDBackRecognizerResult *)result; @@ -1300,6 +1343,7 @@ - (void)scanningViewController:(UIViewController *)sca [self setImageMetadata:imageMetadata forName:[PPDocumentFaceRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPDocumentFaceRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadFrontRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadBackRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadBackRecognizerResult class]]; + [self setImageMetadata:imageMetadata forName:[PPMyTenteraRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyTenteraRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPEudlRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPEudlRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanOldIDRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanOldIDRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanIDFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanIDFrontRecognizerResult class]]; @@ -1313,6 +1357,7 @@ - (void)scanningViewController:(UIViewController *)sca [self setImageMetadata:imageMetadata forName:DOCUMENTDETECTOR_ID1_NAME imageType:PPImageTypeDocument resultClass:[PPDetectorRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadFrontRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPMyKadFrontRecognizerResult class]]; + [self setImageMetadata:imageMetadata forName:[PPMyTenteraRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPMyTenteraRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPDocumentFaceRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPDocumentFaceRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanOldIDRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPGermanOldIDRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanIDFrontRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPGermanIDFrontRecognizerResult class]]; From 039f0b9f9930ebee885a18a01531ecca109e0c75 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:55:48 +0100 Subject: [PATCH 05/18] Added ikad recognizer --- www/index.html | 1 + www/js/ikad_keys.js | 38 ++++++++++++++++++++++++++++++++++++++ www/js/index.js | 15 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 www/js/ikad_keys.js diff --git a/www/index.html b/www/index.html index ff31c58..5cc3967 100644 --- a/www/index.html +++ b/www/index.html @@ -49,6 +49,7 @@

Demo App

+ diff --git a/www/js/ikad_keys.js b/www/js/ikad_keys.js new file mode 100644 index 0000000..7b5fa99 --- /dev/null +++ b/www/js/ikad_keys.js @@ -0,0 +1,38 @@ +// +// ikad_keys.js +// MicroBlink BlinkID library +// +// Copyright (c) 2015 MicroBlink. All rights reserved. +// + + +//pragma mark - Keys for obtaining data on Malaysian identity cards + +var kPPiKadDataType = "PaymentDataType"; + + +var kPPiKadAddress = "iKadAddress.Address"; + + +var kPPiKadDateOfBirth = "iKadDateOfBirth.DateOfBirth"; + + +var kPPiKadEmployer = "iKadEmployer.Employer"; + + +var kPPiKadExpiryDate = "iKadExpiryDate.ExpiryDate"; + + +var kPPiKadName = "iKadName.Name"; + + +var kPPiKadNationality = "iKadNationality.Nationality"; + + +var kPPiKadPassportNumber = "iKadPassportNumber.PassportNumber"; + + +var kPPiKadSector = "iKadSector.Sector"; + + +var kPPiKadSex = "iKadSex.Sex"; diff --git a/www/js/index.js b/www/js/index.js index 3b152f0..cb95089 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -72,6 +72,7 @@ var app = { * DEDL - scans the front side of German driver's license * MyKadFront - scans the front side of Malaysian ID card * MyKadBack - scans the back side of Malaysian ID card + * IKad - scans the front side of IKad card * MyTentera - scans the front side of Malaysian Tentera card * GermanOldID - scans the front side of old German ID card * GermanIDFront - scans the front side of German ID card @@ -258,6 +259,20 @@ var app = { "Religion: " + fields[kPPmyTenteraReligion] + "
" + "Sex: " + fields[kPPmyTenteraSex] + "
"; + } else if (recognizerResult.resultType == "IKad result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "Address: " + fields[kPPiKadAddress] + "
" + + "Birth Date: " + fields[kPPiKadDateOfBirth] + "
" + + "Employer: " + fields[kPPiKadEmployer] + "
" + + "Expiry Date: " + fields[kPPiKadExpiryDate] + "
" + + "Name: " + fields[kPPiKadName] + "
" + + "Nationality: " + fields[kPPiKadNationality] + "
" + + "Passport Number: " + fields[kPPiKadPassportNumber] + "
" + + "Sector: " + fields[kPPiKadSector] + "
" + + "Sex: " + fields[kPPmyKadSex] + "
"; + } else if (recognizerResult.resultType == "GermanOldID result") { resultDiv.innerHTML = /** Personal information */ From efdca81d4c2b412590637611f327bea3b9eae36b Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:56:02 +0100 Subject: [PATCH 06/18] [ios] Added ikad recognizer --- BlinkID/src/ios/sources/CDVBlinkIdScanner.m | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m index aa2fb5d..3ae8988 100644 --- a/BlinkID/src/ios/sources/CDVBlinkIdScanner.m +++ b/BlinkID/src/ios/sources/CDVBlinkIdScanner.m @@ -32,6 +32,7 @@ const NSString *MYKAD_FRONT_TYPE = @"MyKadFront"; const NSString *MYKAD_BACK_TYPE = @"MyKadBack"; const NSString *MYTENTERA_TYPE = @"MyTentera"; +const NSString *IKAD_TYPE = @"IKad"; const NSString *GERMAN_OLD_ID_TYPE = @"GermanOldID"; const NSString *GERMAN_ID_FRONT_TYPE = @"GermanIDFront"; const NSString *GERMAN_ID_BACK_TYPE = @"GermanIDBack"; @@ -65,6 +66,7 @@ NSString *MYKAD_FRONT_RESULT_TYPE = @"MyKadFront result"; NSString *MYKAD_BACK_RESULT_TYPE = @"MyKadBack result"; NSString *MYTENTERA_RESULT_TYPE = @"MyTentera result"; +NSString *IKAD_RESULT_TYPE = @"IKad result"; NSString *BARCODE_RESULT_TYPE = @"Barcode result"; NSString *GERMAN_OLD_ID_RESULT_TYPE = @"GermanOldID result"; NSString *GERMAN_ID_FRONT_RESULT_TYPE = @"GermanFrontID result"; @@ -95,6 +97,8 @@ NSString * MYKAD_FRONT_OWNER_BIRTH_DATE = @"ownerBirthDate"; NSString * MYKAD_BACK_OWNER_BIRTH_DATE = @"MyKadExtendedNRIC.DateOfBirth"; NSString * MYTENTERA_OWNER_BIRTH_DATE = @"MyTenteraNricNumber.OwnerBirthDate"; +NSString * IKAD_DATE_OF_BIRTH = @"iKadDateOfBirth.DateOfBirth"; +NSString * IKAD_EXPIRY_DATE = @"iKadExpiryDate.ExpiryDate"; NSString * GERMAN_ID_DATE_OF_ISSUE = @"DeIDDateOfIssue.DateOfIssue"; NSString * GERMAN_PASS_DATE_OF_ISSUE = @"GermanPassportDateOfIssue.DateOfIssue"; NSString * SINGAPORE_DATE_OF_BIRTH = @"SingaporeIDDOBSex.DateOfBirth"; @@ -427,6 +431,31 @@ - (PPMyTenteraRecognizerSettings *)myTenteraRecognizerSettings { return myTenteraRecognizerSettings; } +- (PPiKadRecognizerSettings *)iKadRecognizerSettings { + + PPiKadRecognizerSettings *iKadRecognizerSettings = [[PPiKadRecognizerSettings alloc] init]; + + // Setup returning document image + + if ([self shouldReturnDocumentImage]) { + iKadRecognizerSettings.displayFullDocumentImage = YES; + + NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPiKadRecognizerResult class]]; + [dict setObject:[NSNull null] forKey:@(PPImageTypeDocument)]; + } + + // Setup returning face image + + if ([self shouldReturnFaceImage]) { + iKadRecognizerSettings.displayFaceImage = YES; + + NSMutableDictionary *dict = [self getInitializedImagesDictionaryForClass:[PPiKadRecognizerResult class]]; + [dict setObject:[NSNull null] forKey:@(PPImageTypeFace)]; + } + + return iKadRecognizerSettings; +} + - (PPGermanOldIDRecognizerSettings *)germanOldIDRecognizerSettings { PPGermanOldIDRecognizerSettings *germanOldIDRecognizerSettings = [[PPGermanOldIDRecognizerSettings alloc] init]; @@ -662,6 +691,10 @@ - (BOOL)shouldUseMyTenteraRecognizerForTypes:(NSArray *)types { return [types containsObject:MYTENTERA_TYPE]; } +- (BOOL)shouldUseIKadRecognizerForTypes:(NSArray *)types { + return [types containsObject:IKAD_TYPE]; +} + - (BOOL)shouldUseGermanOldIDType:(NSArray *)types { return [types containsObject:GERMAN_OLD_ID_TYPE]; } @@ -796,6 +829,10 @@ - (PPCameraCoordinator *)coordinatorWithError:(NSError **)error { [settings.scanSettings addRecognizerSettings:[self myTenteraRecognizerSettings]]; } + if ([self shouldUseIKadRecognizerForTypes:types]) { + [settings.scanSettings addRecognizerSettings:[self iKadRecognizerSettings]]; + } + if ([self shouldUseGermanOldIDType:types]) { [settings.scanSettings addRecognizerSettings:[self germanOldIDRecognizerSettings]]; } @@ -949,6 +986,15 @@ - (void)setDictionary:(NSMutableDictionary *)dict withMyTenteraRecognizerResult: [self setupDictionary:dict withImagesForResult:myTenteraResult]; } +- (void)setDictionary:(NSMutableDictionary *)dict withIKadRecognizerResult:(PPiKadRecognizerResult *)iKadResult { + NSMutableDictionary *stringElements = [NSMutableDictionary dictionaryWithDictionary:[iKadResult getAllStringElements]]; + [stringElements setObject:[iKadResult rawDateOfBirth] forKey:IKAD_DATE_OF_BIRTH]; + [stringElements setObject:[iKadResult rawExpiryDate] forKey:IKAD_EXPIRY_DATE]; + [dict setObject:stringElements forKey:FIELDS]; + [dict setObject:IKAD_RESULT_TYPE forKey:RESULT_TYPE]; + [self setupDictionary:dict withImagesForResult:iKadResult]; +} + - (void)setDictionary:(NSMutableDictionary *)dict withDocumentDetectorResult:(PPDetectorRecognizerResult *)detectorRecognizerResult { [dict setObject:[detectorRecognizerResult getAllStringElements] forKey:FIELDS]; [dict setObject:DOCUMENTDETECTOR_RESULT_TYPE forKey:RESULT_TYPE]; @@ -1157,6 +1203,16 @@ - (void)returnResults:(NSArray *)results cancelled:(BOOL)cancelled { continue; } + if ([result isKindOfClass:[PPiKadRecognizerResult class]]) { + PPiKadRecognizerResult *iKadDecoderResult = (PPiKadRecognizerResult *)result; + + NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; + [self setDictionary:dict withIKadRecognizerResult:iKadDecoderResult]; + + [resultArray addObject:dict]; + continue; + } + if ([result isKindOfClass:[PPUnitedArabEmiratesIDBackRecognizerResult class]]) { PPUnitedArabEmiratesIDBackRecognizerResult *uaeIDBackResult = (PPUnitedArabEmiratesIDBackRecognizerResult *)result; @@ -1344,6 +1400,7 @@ - (void)scanningViewController:(UIViewController *)sca [self setImageMetadata:imageMetadata forName:[PPMyKadFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadFrontRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadBackRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyKadBackRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyTenteraRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPMyTenteraRecognizerResult class]]; + [self setImageMetadata:imageMetadata forName:[PPiKadRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPiKadRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPEudlRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPEudlRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanOldIDRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanOldIDRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanIDFrontRecognizerSettings FULL_DOCUMENT_IMAGE] imageType:PPImageTypeDocument resultClass:[PPGermanIDFrontRecognizerResult class]]; @@ -1357,6 +1414,7 @@ - (void)scanningViewController:(UIViewController *)sca [self setImageMetadata:imageMetadata forName:DOCUMENTDETECTOR_ID1_NAME imageType:PPImageTypeDocument resultClass:[PPDetectorRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyKadFrontRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPMyKadFrontRecognizerResult class]]; + [self setImageMetadata:imageMetadata forName:[PPiKadRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPiKadRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPMyTenteraRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPMyTenteraRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPDocumentFaceRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPDocumentFaceRecognizerResult class]]; [self setImageMetadata:imageMetadata forName:[PPGermanOldIDRecognizerSettings ID_FACE] imageType:PPImageTypeFace resultClass:[PPGermanOldIDRecognizerResult class]]; From f3a0517590fc61922f5c492239d86e31117819ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Vidakovic=CC=81?= Date: Wed, 21 Mar 2018 12:18:23 +0100 Subject: [PATCH 07/18] [android] added suport for mykad back --- .../plugins/blinkid/BlinkIdScanner.java | 39 ++++++++++++++----- .../plugins/blinkid/RecognizerType.java | 6 ++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java index 72d1405..3240899 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java @@ -47,6 +47,8 @@ import com.microblink.recognizers.blinkid.germany.old.front.GermanOldIDRecognizerSettings; import com.microblink.recognizers.blinkid.germany.passport.GermanPassportRecognitionResult; import com.microblink.recognizers.blinkid.germany.passport.GermanPassportRecognizerSettings; +import com.microblink.recognizers.blinkid.malaysia.mykad.back.MyKadBackSideRecognitionResult; +import com.microblink.recognizers.blinkid.malaysia.mykad.back.MyKadBackSideRecognizerSettings; import com.microblink.recognizers.blinkid.malaysia.mykad.front.MyKadFrontSideRecognitionResult; import com.microblink.recognizers.blinkid.malaysia.mykad.front.MyKadFrontSideRecognizerSettings; import com.microblink.recognizers.blinkid.mrtd.MRTDRecognitionResult; @@ -98,7 +100,8 @@ public class BlinkIdScanner extends CordovaPlugin { private static final String SINGAPORE_ID_FRONT_RESULT = "SingaporeFrontID result"; private static final String SINGAPORE_ID_BACK_RESULT = "SingaporeBackID result"; private static final String MRTD_RESULT_TYPE = "MRTD result"; - private static final String MYKAD_RESULT_TYPE = "MyKad result"; + private static final String MYKAD_FRONT_RESULT_TYPE = "MyKadFront result"; + private static final String MYKAD_BACK_RESULT_TYPE = "MyKadBack result"; private static final String PDF417_RESULT_TYPE = "Barcode result"; private static final String UKDL_RESULT_TYPE = "UKDL result"; private static final String UAE_ID_BACK_RESULT_TYPE = "UnitedArabEmiratesIDBack result"; @@ -308,8 +311,10 @@ private RecognizerSettings buildRecognizerSettings(String recognizerId) { return buildDedlSettings(); case EUDL: return buildEudlSettings(); - case MYKAD: - return buildMyKadSettings(); + case MYKAD_FRONT: + return buildMyKadFrontSettings(); + case MYKAD_BACK: + return buildMyKadBackSettings(); case BARCODE: return buildBarcodeSettings(); case GERMAN_OLD_ID: @@ -437,8 +442,7 @@ private void eudlConfigureImageReturn(EUDLRecognizerSettings settings) { } } - private MyKadFrontSideRecognizerSettings buildMyKadSettings() { - // prepare settings for Malaysian MyKad ID document recognizer + private MyKadFrontSideRecognizerSettings buildMyKadFrontSettings() { MyKadFrontSideRecognizerSettings myKad = new MyKadFrontSideRecognizerSettings(); if (sReturnDocumentImage) { myKad.setShowFullDocument(true); @@ -451,6 +455,15 @@ private MyKadFrontSideRecognizerSettings buildMyKadSettings() { return myKad; } + private MyKadBackSideRecognizerSettings buildMyKadBackSettings() { + MyKadBackSideRecognizerSettings settings = new MyKadBackSideRecognizerSettings(); + if (sReturnDocumentImage) { + settings.setDisplayFullDocumentImage(true); + sFullDocumentImageResultTypes.put(MyKadBackSideRecognizerSettings.FULL_DOCUMENT_IMAGE_NAME, MyKadBackSideRecognitionResult.class); + } + return settings; + } + private USDLRecognizerSettings buildUsdlSettings() { // prepare settings for US Driver's Licence recognizer USDLRecognizerSettings usdl = new USDLRecognizerSettings(); @@ -676,7 +689,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } else if (res instanceof EUDLRecognitionResult) { // check if scan result is result of EUDL recognizer resultsList.put(buildEUDLResult((EUDLRecognitionResult) res)); } else if (res instanceof MyKadFrontSideRecognitionResult) { // check if scan result is result of MyKad recognizer - resultsList.put(buildMyKadResult((MyKadFrontSideRecognitionResult) res)); + resultsList.put(buildMyKadFrontResult((MyKadFrontSideRecognitionResult) res)); + } else if (res instanceof MyKadBackSideRecognitionResult) { + resultsList.put(buildMyKadBackResult((MyKadBackSideRecognitionResult) res)); } else if (res instanceof BarcodeScanResult) { // check if scan result is result of Barcode recognizer resultsList.put(buildBarcodeResult((BarcodeScanResult) res)); } else if (res instanceof GermanOldIDRecognitionResult) { // check if scan result is result of German Old ID recognizer @@ -822,13 +837,19 @@ private JSONObject buildUSDLResult(USDLScanResult res) throws JSONException { return buildKeyValueResult(res, USDL_RESULT_TYPE); } - private JSONObject buildMyKadResult(MyKadFrontSideRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, MYKAD_RESULT_TYPE); + private JSONObject buildMyKadFrontResult(MyKadFrontSideRecognitionResult res) throws JSONException { + JSONObject result = buildKeyValueResult(res, MYKAD_FRONT_RESULT_TYPE); putDocumentImageToResultJson(result, MyKadFrontSideRecognitionResult.class); putFaceImageToResultJson(result, MyKadFrontSideRecognitionResult.class); return result; } - + + private JSONObject buildMyKadBackResult(MyKadBackSideRecognitionResult res) throws JSONException { + JSONObject result = buildKeyValueResult(res, MYKAD_BACK_RESULT_TYPE); + putDocumentImageToResultJson(result, MyKadBackSideRecognitionResult.class); + return result; + } + private JSONObject buildEUDLResult(EUDLRecognitionResult res) throws JSONException{ String resultType; diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java index f72016b..fccee48 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java @@ -9,9 +9,13 @@ enum RecognizerType { EUDL("EUDL"), USDL("USDL"), MRTD("MRTD"), - MYKAD("MyKad"), PDF417("PDF417"), UKDL("UKDL"), + + MYKAD_FRONT("MyKadFront"), + MYKAD_BACK("MyKadBack"), + IKAD("IKad"), + MY_TENTERA("MyTentera"), GERMAN_ID_BACK("GermanIDBack"), GERMAN_ID_FRONT("GermanIDFront"), From 00452404b48dea77fd0b865ff7105453bb955484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Vidakovic=CC=81?= Date: Wed, 21 Mar 2018 13:37:21 +0100 Subject: [PATCH 08/18] moved result id constants to Recognizer type enum --- .../plugins/blinkid/BlinkIdScanner.java | 166 ++++++++---------- .../plugins/blinkid/RecognizerType.java | 58 +++--- 2 files changed, 105 insertions(+), 119 deletions(-) diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java index 3240899..5101476 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java @@ -87,27 +87,6 @@ public class BlinkIdScanner extends CordovaPlugin { private static final int REQUEST_CODE = 1337; - // keys for result types - private static final String BARCODE_RESULT_TYPE = "Barcode result"; - private static final String DEDL_RESULT_TYPE = "DEDL result"; - private static final String DOCUMENTDETECTOR_RESULT_TYPE = "DocumentDetector result"; - private static final String DOCUMENTFACE_RESULT_TYPE = "DocumentFace result"; - private static final String EUDL_RESULT_TYPE = "EUDL result"; - private static final String GERMAN_ID_BACK_RESULT_TYPE = "GermanBackID result"; - private static final String GERMAN_ID_FRONT_RESULT_TYPE = "GermanFrontID result"; - private static final String GERMAN_OLD_ID_RESULT_TYPE = "GermanOldID result"; - private static final String GERMAN_PASS_RESULT_TYPE = "GermanPassport result"; - private static final String SINGAPORE_ID_FRONT_RESULT = "SingaporeFrontID result"; - private static final String SINGAPORE_ID_BACK_RESULT = "SingaporeBackID result"; - private static final String MRTD_RESULT_TYPE = "MRTD result"; - private static final String MYKAD_FRONT_RESULT_TYPE = "MyKadFront result"; - private static final String MYKAD_BACK_RESULT_TYPE = "MyKadBack result"; - private static final String PDF417_RESULT_TYPE = "Barcode result"; - private static final String UKDL_RESULT_TYPE = "UKDL result"; - private static final String UAE_ID_BACK_RESULT_TYPE = "UnitedArabEmiratesIDBack result"; - private static final String UAE_ID_FRONT_RESULT_TYPE = "UnitedArabEmiratesIDFront result"; - private static final String USDL_RESULT_TYPE = "USDL result"; - // image names private static final String FULL_DOCUMENT_DETECTOR_IMAGE_ID1 = "IDCard"; private static final String FULL_DOCUMENT_DETECTOR_IMAGE_ID2 = "ID2Card"; @@ -205,7 +184,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo String language = null; if (!args.isNull(4)) { - language = args.optString(4); + language = args.optString(4); } scan(types, licenseKey, language); @@ -415,7 +394,7 @@ private EUDLRecognizerSettings buildDedlSettings() { eudlConfigureImageReturn(dedl); return dedl; } - + private EUDLRecognizerSettings buildEudlSettings() { // To specify we want to perform EUDL (EU Driver's License) recognition, // prepare settings for EUDL recognizer. Pass country as parameter to EUDLRecognizerSettings @@ -475,7 +454,7 @@ private USDLRecognizerSettings buildUsdlSettings() { // surrounding it (e.g. text concatenated with barcode). This option can significantly // increase recognition time. Default is true. usdl.setNullQuietZoneAllowed(true); - + return usdl; } @@ -522,7 +501,7 @@ private BarcodeRecognizerSettings buildBarcodeSettings() { barcode.setSlowThoroughScan(true); return barcode; } - + private GermanOldIDRecognizerSettings buildGermanOldIDSettings() { // prepare settings for the GermanIDFrontSide recognizer GermanOldIDRecognizerSettings settings = new GermanOldIDRecognizerSettings(); @@ -682,40 +661,45 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { for (BaseRecognitionResult res : resultArray) { try { - if (res instanceof Pdf417ScanResult) { // check if scan result is result of Pdf417 recognizer - resultsList.put(buildPdf417Result((Pdf417ScanResult) res)); - } else if (res instanceof USDLScanResult) { // check if scan result is result of US Driver's Licence recognizer - resultsList.put(buildUSDLResult((USDLScanResult) res)); - } else if (res instanceof EUDLRecognitionResult) { // check if scan result is result of EUDL recognizer - resultsList.put(buildEUDLResult((EUDLRecognitionResult) res)); - } else if (res instanceof MyKadFrontSideRecognitionResult) { // check if scan result is result of MyKad recognizer - resultsList.put(buildMyKadFrontResult((MyKadFrontSideRecognitionResult) res)); + JSONObject jsonResult = null; + if (res instanceof Pdf417ScanResult) { + jsonResult = buildPdf417Result((Pdf417ScanResult) res); + } else if (res instanceof USDLScanResult) { + jsonResult = buildUSDLResult((USDLScanResult) res); + } else if (res instanceof EUDLRecognitionResult) { + jsonResult = buildEUDLResult((EUDLRecognitionResult) res); + } else if (res instanceof MyKadFrontSideRecognitionResult) { + jsonResult = buildMyKadFrontResult((MyKadFrontSideRecognitionResult) res); } else if (res instanceof MyKadBackSideRecognitionResult) { - resultsList.put(buildMyKadBackResult((MyKadBackSideRecognitionResult) res)); - } else if (res instanceof BarcodeScanResult) { // check if scan result is result of Barcode recognizer - resultsList.put(buildBarcodeResult((BarcodeScanResult) res)); - } else if (res instanceof GermanOldIDRecognitionResult) { // check if scan result is result of German Old ID recognizer - resultsList.put(buildGermanOldIDResult((GermanOldIDRecognitionResult) res)); - } else if (res instanceof GermanIDFrontSideRecognitionResult) { // check if scan result is result of German ID Front recognizer - resultsList.put(buildGermanIDFrontResult((GermanIDFrontSideRecognitionResult) res)); - } else if (res instanceof GermanIDBackSideRecognitionResult) { // check if scan result is result of German ID Back recognizer - resultsList.put(buildGermanIDBackResult((GermanIDBackSideRecognitionResult) res)); - } else if (res instanceof GermanPassportRecognitionResult) { // check if scan result is result of German Passport recognizer - resultsList.put(buildGermanPassResult((GermanPassportRecognitionResult) res)); + jsonResult = buildMyKadBackResult((MyKadBackSideRecognitionResult) res); + } else if (res instanceof BarcodeScanResult) { + jsonResult = buildBarcodeResult((BarcodeScanResult) res); + } else if (res instanceof GermanOldIDRecognitionResult) { + jsonResult = buildGermanOldIDResult((GermanOldIDRecognitionResult) res); + } else if (res instanceof GermanIDFrontSideRecognitionResult) { + jsonResult = buildGermanIDFrontResult((GermanIDFrontSideRecognitionResult) res); + } else if (res instanceof GermanIDBackSideRecognitionResult) { + jsonResult = buildGermanIDBackResult((GermanIDBackSideRecognitionResult) res); + } else if (res instanceof GermanPassportRecognitionResult) { + jsonResult = buildGermanPassResult((GermanPassportRecognitionResult) res); } else if (res instanceof UnitedArabEmiratesIDFrontRecognitionResult) { - resultsList.put(buildUaeIDFrontResult((UnitedArabEmiratesIDFrontRecognitionResult) res)); + jsonResult = buildUaeIDFrontResult((UnitedArabEmiratesIDFrontRecognitionResult) res); } else if (res instanceof UnitedArabEmiratesIDBackRecognitionResult) { - resultsList.put(buildUaeIDBackResult((UnitedArabEmiratesIDBackRecognitionResult) res)); + jsonResult = buildUaeIDBackResult((UnitedArabEmiratesIDBackRecognitionResult) res); } else if (res instanceof SingaporeIDFrontRecognitionResult) { - resultsList.put(buildSingaporeIDFrontResult((SingaporeIDFrontRecognitionResult) res)); + jsonResult = buildSingaporeIDFrontResult((SingaporeIDFrontRecognitionResult) res); } else if (res instanceof SingaporeIDBackRecognitionResult) { - resultsList.put(buildSingaporeIDBackResult((SingaporeIDBackRecognitionResult) res)); - } else if (res instanceof MRTDRecognitionResult) { // check if scan result is result of MRTD recognizer - resultsList.put(buildMRTDResult((MRTDRecognitionResult) res)); - } else if (res instanceof DocumentFaceRecognitionResult) { // check if scan result is result of Document Face recognizer - resultsList.put(buildDocumentFaceResult((DocumentFaceRecognitionResult) res)); - } else if (res instanceof DetectorRecognitionResult) { // check if scan result is result of Detector recognizer - resultsList.put(buildDetectorRecognitionResult((DetectorRecognitionResult) res)); + jsonResult = buildSingaporeIDBackResult((SingaporeIDBackRecognitionResult) res); + } else if (res instanceof MRTDRecognitionResult) { + jsonResult = buildMRTDResult((MRTDRecognitionResult) res); + } else if (res instanceof DocumentFaceRecognitionResult) { + jsonResult = buildDocumentFaceResult((DocumentFaceRecognitionResult) res); + } else if (res instanceof DetectorRecognitionResult) { + jsonResult = buildDetectorRecognitionResult((DetectorRecognitionResult) res); + } + + if(jsonResult != null) { + resultsList.put(jsonResult); } } catch (Exception e) { Log.e(LOG_TAG, "Error parsing " + res.getClass().getName()); @@ -813,7 +797,7 @@ private JSONObject buildPdf417Result(Pdf417ScanResult res) throws JSONException byte[] rawDataBuffer = rawData.getAllData(); JSONObject result = new JSONObject(); - result.put(RESULT_TYPE, PDF417_RESULT_TYPE); + result.put(RESULT_TYPE, RecognizerType.PDF417.resultId); result.put(TYPE, "PDF417"); result.put(DATA, barcodeData); result.put(RAW_DATA, byteArrayToHex(rawDataBuffer)); @@ -827,119 +811,119 @@ private JSONObject buildBarcodeResult(BarcodeScanResult res) throws JSONExceptio String barcodeData = res.getStringData(); JSONObject result = new JSONObject(); - result.put(RESULT_TYPE, BARCODE_RESULT_TYPE); + result.put(RESULT_TYPE, RecognizerType.BARCODE.resultId); result.put(TYPE, type.name()); result.put(DATA, barcodeData); return result; } private JSONObject buildUSDLResult(USDLScanResult res) throws JSONException { - return buildKeyValueResult(res, USDL_RESULT_TYPE); + return buildKeyValueResult(res, RecognizerType.USDL.resultId); } private JSONObject buildMyKadFrontResult(MyKadFrontSideRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, MYKAD_FRONT_RESULT_TYPE); - putDocumentImageToResultJson(result, MyKadFrontSideRecognitionResult.class); - putFaceImageToResultJson(result, MyKadFrontSideRecognitionResult.class); - return result; + JSONObject result = buildKeyValueResult(res, RecognizerType.MYKAD_FRONT.resultId); + putDocumentImageToResultJson(result, MyKadFrontSideRecognitionResult.class); + putFaceImageToResultJson(result, MyKadFrontSideRecognitionResult.class); + return result; } private JSONObject buildMyKadBackResult(MyKadBackSideRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, MYKAD_BACK_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.MYKAD_BACK.resultId); putDocumentImageToResultJson(result, MyKadBackSideRecognitionResult.class); return result; } private JSONObject buildEUDLResult(EUDLRecognitionResult res) throws JSONException{ - String resultType; - - // Select the result type by country. - switch(res.getCountry()) { - case EUDL_COUNTRY_UK: - resultType = UKDL_RESULT_TYPE; - break; - case EUDL_COUNTRY_GERMANY: - resultType = DEDL_RESULT_TYPE; - break; - default: - resultType = EUDL_RESULT_TYPE; - } - JSONObject result = buildKeyValueResult(res, resultType); - putDocumentImageToResultJson(result, EUDLRecognitionResult.class); - putFaceImageToResultJson(result, EUDLRecognitionResult.class); - return result; + String resultType; + + // Select the result type by country. + switch(res.getCountry()) { + case EUDL_COUNTRY_UK: + resultType = RecognizerType.UKDL.resultId; + break; + case EUDL_COUNTRY_GERMANY: + resultType = RecognizerType.DEDL.resultId; + break; + default: + resultType = RecognizerType.EUDL.resultId; + } + JSONObject result = buildKeyValueResult(res, resultType); + putDocumentImageToResultJson(result, EUDLRecognitionResult.class); + putFaceImageToResultJson(result, EUDLRecognitionResult.class); + return result; } private JSONObject buildMRTDResult(MRTDRecognitionResult res) throws JSONException{ - JSONObject result = buildKeyValueResult(res, MRTD_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.MRTD.resultId); putDocumentImageToResultJson(result, MRTDRecognitionResult.class); return result; } - + private JSONObject buildDocumentFaceResult(DocumentFaceRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, DOCUMENTFACE_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.DOCUMENTFACE.resultId); putDocumentImageToResultJson(result, DocumentFaceRecognitionResult.class); putFaceImageToResultJson(result, DocumentFaceRecognitionResult.class); return result; } private JSONObject buildDetectorRecognitionResult(DetectorRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, DOCUMENTDETECTOR_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.DOCUMENTDETECTOR.resultId); putDocumentImageToResultJson(result, DetectorRecognitionResult.class); return result; } private JSONObject buildGermanOldIDResult(GermanOldIDRecognitionResult res)throws JSONException { - JSONObject result = buildKeyValueResult(res, GERMAN_OLD_ID_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.GERMAN_OLD_ID.resultId); putDocumentImageToResultJson(result, GermanOldIDRecognitionResult.class); putFaceImageToResultJson(result, GermanOldIDRecognitionResult.class); return result; } private JSONObject buildGermanIDFrontResult(GermanIDFrontSideRecognitionResult res)throws JSONException { - JSONObject result = buildKeyValueResult(res, GERMAN_ID_FRONT_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.GERMAN_ID_FRONT.resultId); putDocumentImageToResultJson(result, GermanIDFrontSideRecognitionResult.class); putFaceImageToResultJson(result, GermanIDFrontSideRecognitionResult.class); return result; } private JSONObject buildGermanIDBackResult(GermanIDBackSideRecognitionResult res) throws JSONException{ - JSONObject result = buildKeyValueResult(res, GERMAN_ID_BACK_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.GERMAN_ID_BACK.resultId); putDocumentImageToResultJson(result, GermanIDBackSideRecognitionResult.class); putFaceImageToResultJson(result, GermanIDBackSideRecognitionResult.class); return result; } private JSONObject buildGermanPassResult(GermanPassportRecognitionResult res) throws JSONException{ - JSONObject result = buildKeyValueResult(res, GERMAN_PASS_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.GERMAN_PASSPORT.resultId); putDocumentImageToResultJson(result, GermanPassportRecognitionResult.class); putFaceImageToResultJson(result, GermanPassportRecognitionResult.class); return result; } private JSONObject buildSingaporeIDFrontResult(SingaporeIDFrontRecognitionResult res) throws JSONException { - JSONObject result = buildKeyValueResult(res, SINGAPORE_ID_FRONT_RESULT); + JSONObject result = buildKeyValueResult(res, RecognizerType.SINGAPORE_ID_FRONT.resultId); putDocumentImageToResultJson(result, SingaporeIDFrontRecognitionResult.class); putFaceImageToResultJson(result, SingaporeIDFrontRecognitionResult.class); return result; } private JSONObject buildSingaporeIDBackResult(SingaporeIDBackRecognitionResult res)throws JSONException { - JSONObject result = buildKeyValueResult(res, SINGAPORE_ID_BACK_RESULT); + JSONObject result = buildKeyValueResult(res, RecognizerType.SINGAPORE_ID_BACK.resultId); putDocumentImageToResultJson(result, SingaporeIDBackRecognitionResult.class); putFaceImageToResultJson(result, SingaporeIDBackRecognitionResult.class); return result; } private JSONObject buildUaeIDFrontResult(UnitedArabEmiratesIDFrontRecognitionResult res) throws JSONException{ - JSONObject result = buildKeyValueResult(res, UAE_ID_FRONT_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.UAE_ID_FRONT.resultId); putDocumentImageToResultJson(result, UnitedArabEmiratesIDFrontRecognitionResult.class); putFaceImageToResultJson(result, UnitedArabEmiratesIDFrontRecognitionResult.class); return result; } private JSONObject buildUaeIDBackResult(UnitedArabEmiratesIDBackRecognitionResult res) throws JSONException{ - JSONObject result = buildKeyValueResult(res, UAE_ID_BACK_RESULT_TYPE); + JSONObject result = buildKeyValueResult(res, RecognizerType.UAE_ID_BACK.resultId); putDocumentImageToResultJson(result, UnitedArabEmiratesIDBackRecognitionResult.class); putFaceImageToResultJson(result, UnitedArabEmiratesIDBackRecognitionResult.class); return result; diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java index fccee48..1891480 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/RecognizerType.java @@ -2,38 +2,40 @@ enum RecognizerType { - DOCUMENTFACE("DocumentFace"), - BARCODE("Barcode"), - DEDL("DEDL"), - DOCUMENTDETECTOR("DocumentDetector"), - EUDL("EUDL"), - USDL("USDL"), - MRTD("MRTD"), - PDF417("PDF417"), - UKDL("UKDL"), - - MYKAD_FRONT("MyKadFront"), - MYKAD_BACK("MyKadBack"), - IKAD("IKad"), - MY_TENTERA("MyTentera"), - - GERMAN_ID_BACK("GermanIDBack"), - GERMAN_ID_FRONT("GermanIDFront"), - GERMAN_OLD_ID("GermanOldID"), - GERMAN_PASSPORT("GermanPassport"), - - SINGAPORE_ID_FRONT("SingaporeIDFront"), - SINGAPORE_ID_BACK("SingaporeIDBack"), - - UAE_ID_BACK("UnitedArabEmiratesIDBack"), - UAE_ID_FRONT("UnitedArabEmiratesIDFront"), - - UNKNOWN(""); + DOCUMENTFACE("DocumentFace", "DocumentFace result"), + BARCODE("Barcode", "Barcode result"), + DEDL("DEDL", "DEDL result"), + DOCUMENTDETECTOR("DocumentDetector", "DocumentDetector result"), + EUDL("EUDL", "EUDL result"), + USDL("USDL", "USDL result"), + MRTD("MRTD", "MRTD result"), + PDF417("PDF417", "Barcode result"), + UKDL("UKDL", "UKDL result"), + + MYKAD_FRONT("MyKadFront", "MyKadFront result"), + MYKAD_BACK("MyKadBack", "MyKadBack result"), + IKAD("IKad", "IKad result"), + MY_TENTERA("MyTentera", "MyTentera result"), + + GERMAN_ID_BACK("GermanIDBack", "GermanBackID result"), + GERMAN_ID_FRONT("GermanIDFront", "GermanFrontID result"), + GERMAN_OLD_ID("GermanOldID", "GermanOldID result"), + GERMAN_PASSPORT("GermanPassport", "GermanPassport result"), + + SINGAPORE_ID_FRONT("SingaporeIDFront", "SingaporeFrontID result"), + SINGAPORE_ID_BACK("SingaporeIDBack", "SingaporeBackID result"), + + UAE_ID_BACK("UnitedArabEmiratesIDBack", "UnitedArabEmiratesIDBack result"), + UAE_ID_FRONT("UnitedArabEmiratesIDFront", "UnitedArabEmiratesIDFront result"), + + UNKNOWN("", ""); public final String id; + public final String resultId; - RecognizerType(String id) { + RecognizerType(String id, String resultId) { this.id = id; + this.resultId = resultId; } static RecognizerType fromId(String id) { From b716694148e281d8722b3d97bcfd5bf596c60933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Vidakovic=CC=81?= Date: Wed, 21 Mar 2018 14:34:48 +0100 Subject: [PATCH 09/18] [android] added support for myTentera and Ikad --- .../plugins/blinkid/BlinkIdScanner.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java index 5101476..6a877c2 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java @@ -47,10 +47,14 @@ import com.microblink.recognizers.blinkid.germany.old.front.GermanOldIDRecognizerSettings; import com.microblink.recognizers.blinkid.germany.passport.GermanPassportRecognitionResult; import com.microblink.recognizers.blinkid.germany.passport.GermanPassportRecognizerSettings; +import com.microblink.recognizers.blinkid.malaysia.ikad.IKadRecognitionResult; +import com.microblink.recognizers.blinkid.malaysia.ikad.IKadRecognizerSettings; import com.microblink.recognizers.blinkid.malaysia.mykad.back.MyKadBackSideRecognitionResult; import com.microblink.recognizers.blinkid.malaysia.mykad.back.MyKadBackSideRecognizerSettings; import com.microblink.recognizers.blinkid.malaysia.mykad.front.MyKadFrontSideRecognitionResult; import com.microblink.recognizers.blinkid.malaysia.mykad.front.MyKadFrontSideRecognizerSettings; +import com.microblink.recognizers.blinkid.malaysia.tentera.MyTenteraRecognitionResult; +import com.microblink.recognizers.blinkid.malaysia.tentera.MyTenteraRecognizerSettings; import com.microblink.recognizers.blinkid.mrtd.MRTDRecognitionResult; import com.microblink.recognizers.blinkid.mrtd.MRTDRecognizerSettings; import com.microblink.recognizers.blinkid.singapore.back.SingaporeIDBackRecognitionResult; @@ -294,6 +298,10 @@ private RecognizerSettings buildRecognizerSettings(String recognizerId) { return buildMyKadFrontSettings(); case MYKAD_BACK: return buildMyKadBackSettings(); + case IKAD: + return buildIkadSettings(); + case MY_TENTERA: + return buildMyTenteraSettings(); case BARCODE: return buildBarcodeSettings(); case GERMAN_OLD_ID: @@ -443,6 +451,38 @@ private MyKadBackSideRecognizerSettings buildMyKadBackSettings() { return settings; } + private IKadRecognizerSettings buildIkadSettings() { + IKadRecognizerSettings settings = new IKadRecognizerSettings(); + + if(sReturnDocumentImage) { + settings.setShowFullDocumentImage(true); + sFullDocumentImageResultTypes.put(IKadRecognizerSettings.FULL_DOCUMENT_IMAGE, IKadRecognitionResult.class); + } + + if(sReturnFaceImage) { + settings.setShowFaceImage(true); + sFaceImageResultTypes.put(IKadRecognizerSettings.FACE_IMAGE_NAME, IKadRecognitionResult.class); + } + + return settings; + } + + private MyTenteraRecognizerSettings buildMyTenteraSettings() { + MyTenteraRecognizerSettings settings = new MyTenteraRecognizerSettings(); + + if(sReturnDocumentImage) { + settings.setShowFullDocument(true); + sFullDocumentImageResultTypes.put(MyTenteraRecognizerSettings.FULL_DOCUMENT_IMAGE, MyTenteraRecognitionResult.class); + } + + if(sReturnFaceImage) { + settings.setShowFaceImage(true); + sFaceImageResultTypes.put(MyTenteraRecognizerSettings.FACE_IMAGE_NAME, MyTenteraRecognitionResult.class); + } + + return settings; + } + private USDLRecognizerSettings buildUsdlSettings() { // prepare settings for US Driver's Licence recognizer USDLRecognizerSettings usdl = new USDLRecognizerSettings(); @@ -672,6 +712,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { jsonResult = buildMyKadFrontResult((MyKadFrontSideRecognitionResult) res); } else if (res instanceof MyKadBackSideRecognitionResult) { jsonResult = buildMyKadBackResult((MyKadBackSideRecognitionResult) res); + } else if (res instanceof IKadRecognitionResult) { + jsonResult = buildIkadResult((IKadRecognitionResult) res); + } else if (res instanceof MyTenteraRecognitionResult) { + jsonResult = buildMyTenteraResult((MyTenteraRecognitionResult) res); } else if (res instanceof BarcodeScanResult) { jsonResult = buildBarcodeResult((BarcodeScanResult) res); } else if (res instanceof GermanOldIDRecognitionResult) { @@ -834,6 +878,20 @@ private JSONObject buildMyKadBackResult(MyKadBackSideRecognitionResult res) thro return result; } + private JSONObject buildIkadResult(IKadRecognitionResult res) throws JSONException { + JSONObject result = buildKeyValueResult(res, RecognizerType.IKAD.resultId); + putDocumentImageToResultJson(result, IKadRecognitionResult.class); + putFaceImageToResultJson(result, IKadRecognitionResult.class); + return result; + } + + private JSONObject buildMyTenteraResult(MyTenteraRecognitionResult res) throws JSONException { + JSONObject result = buildKeyValueResult(res, RecognizerType.MY_TENTERA.resultId); + putDocumentImageToResultJson(result, MyTenteraRecognitionResult.class); + putFaceImageToResultJson(result, MyTenteraRecognitionResult.class); + return result; + } + private JSONObject buildEUDLResult(EUDLRecognitionResult res) throws JSONException{ String resultType; From 96024da0f3a93c02957bca402e8fa90bc6d977e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Vidakovic=CC=81?= Date: Wed, 21 Mar 2018 15:06:18 +0100 Subject: [PATCH 10/18] fix for nric number undefined --- www/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/index.js b/www/js/index.js index cb95089..0c452ad 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -238,7 +238,7 @@ var app = { resultDiv.innerHTML = /** Personal information */ "ID Type: " + fields[kPPDataType] + "
" + - "NRIC Number: " + fields[kPPmyKadNricNumber] + "
" + + "NRIC Number: " + fields[kPPmyKadBackNricNumber] + "
" + "Extended NRIC Number: " + fields[kPPmyKadBackExtendedNricNumber] + "
" + "Birth Date: " + fields[kPPmyKadBackBirthDate] + "
" + "Sex: " + fields[kPPmyKadBackSex] + "
"; From a34b76c63138df412b4d3d6bad7e68aa05939d05 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Tue, 20 Mar 2018 13:56:40 +0100 Subject: [PATCH 11/18] Updated index.js script --- www/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/index.js b/www/js/index.js index 0c452ad..60df3e3 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -62,7 +62,7 @@ var app = { /** * Use these scanner types - * Available: "PDF417", "USDL", "Barcode", "MRTD", "EUDL", "UKDL", "DEDL", "MyKad", "GermanOldID", "GermanIDFront", "GermanIDBack", "GermanPassport", "UnitedArabEmiratesIDFront", "UnitedArabEmiratesIDBack", "SingaporeIDFront", "SingaporeIDBack", "DocumentFace", "DocumentDetector" + * Available: "PDF417", "USDL", "Barcode", "MRTD", "EUDL", "UKDL", "DEDL", "MyKadFront", "MyKadBack", "IKad", "MyTentera", "GermanOldID", "GermanIDFront", "GermanIDBack", "GermanPassport", "UnitedArabEmiratesIDFront", "UnitedArabEmiratesIDBack", "SingaporeIDFront", "SingaporeIDBack", "DocumentFace", "DocumentDetector" * PDF417 - scans PDF417 barcodes * USDL - scans barcodes located on the back of US driver's license * Barcode - scans various types of codes (i.e. QR, UPCA, UPCE...). Types of scanned codes can be modified in plugin classes (Explained later in this readme). By default, scanned codes are set to: Code 39, Code 128, EAN 13, EAN 8, QR, UPCA, UPCE From d077a483775849e8b8a83e782635f9cb6b0cc6f2 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 08:21:12 +0200 Subject: [PATCH 12/18] Fixed ikad key in index.js --- www/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/index.js b/www/js/index.js index 60df3e3..49a703b 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -271,7 +271,7 @@ var app = { "Nationality: " + fields[kPPiKadNationality] + "
" + "Passport Number: " + fields[kPPiKadPassportNumber] + "
" + "Sector: " + fields[kPPiKadSector] + "
" + - "Sex: " + fields[kPPmyKadSex] + "
"; + "Sex: " + fields[kPPiKadSex] + "
"; } else if (recognizerResult.resultType == "GermanOldID result") { From 8b8b4312b83066375334117f5d1d2d64d14251db Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 10:32:13 +0200 Subject: [PATCH 13/18] Updated ios framework to v2.16.1 --- BlinkID/initIOSFramework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlinkID/initIOSFramework.sh b/BlinkID/initIOSFramework.sh index 4bcb020..345024e 100755 --- a/BlinkID/initIOSFramework.sh +++ b/BlinkID/initIOSFramework.sh @@ -3,7 +3,7 @@ # enter into ios project folder pushd src/ios/ -VERSION='2.16.0' +VERSION='2.16.1' # check if Microblink framework and bundle already exist if [ ! -d 'blinkid-ios' ] ; then From feeee1a113f798f935cad1d82d8efe438cfd6260 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 10:32:29 +0200 Subject: [PATCH 14/18] Updated README with new types --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 39acb38..d85d461 100644 --- a/README.md +++ b/README.md @@ -169,9 +169,9 @@ To run the script, you'll need BASH environment on Windows (Linux and MacOS use To use the plugin you call it in your Javascript code like the demo application: ```javascript - /** +/** * Use these scanner types - * Available: "PDF417", "USDL", "Barcode", "MRTD", "EUDL", "UKDL", "DEDL", "MyKad", "GermanOldID", "GermanIDFront", "GermanIDBack", "GermanPassport", "UnitedArabEmiratesIDFront", "UnitedArabEmiratesIDBack", "SingaporeIDFront", "SingaporeIDBack", "DocumentFace", "DocumentDetector" + * Available: "PDF417", "USDL", "Barcode", "MRTD", "EUDL", "UKDL", "DEDL", "MyKadFront", "MyKadBack", "IKad", "MyTentera", "GermanOldID", "GermanIDFront", "GermanIDBack", "GermanPassport", "UnitedArabEmiratesIDFront", "UnitedArabEmiratesIDBack", "SingaporeIDFront", "SingaporeIDBack", "DocumentFace", "DocumentDetector" * PDF417 - scans PDF417 barcodes * USDL - scans barcodes located on the back of US driver's license * Barcode - scans various types of codes (i.e. QR, UPCA, UPCE...). Types of scanned codes can be modified in plugin classes (Explained later in this readme). By default, scanned codes are set to: Code 39, Code 128, EAN 13, EAN 8, QR, UPCA, UPCE @@ -179,7 +179,10 @@ To use the plugin you call it in your Javascript code like the demo application: * EUDL - scans the front side of European driver's license * UKDL - scans the front side of United Kingom driver's license * DEDL - scans the front side of German driver's license - * MyKad - scans the front side of Malaysian ID card + * MyKadFront - scans the front side of Malaysian ID card + * MyKadBack - scans the back side of Malaysian ID card + * IKad - scans the front side of IKad card + * MyTentera - scans the front side of Malaysian Tentera card * GermanOldID - scans the front side of old German ID card * GermanIDFront - scans the front side of German ID card * GermanIDBack - scans the back side of German ID card @@ -193,7 +196,7 @@ To use the plugin you call it in your Javascript code like the demo application: * * Variable << types >> declared below has to contain all the scanners needed by your application. Applying additional scanners will slow down the scanning process */ -var types = ["USDL", "MRTD", "Barcode"];; +var types = ["USDL", "MRTD", "Barcode"]; /** * Image type defines type of the image that will be returned in scan result (image is returned as Base64 encoded JPEG) @@ -325,7 +328,7 @@ scanButton.addEventListener('click', function() { "First name: " + fields[kPPeudlFirstName] + "
" + "Last name: " + fields[kPPeudlLastName] + "
"; - } else if (recognizerResult.resultType == "MyKad result") { + } else if (recognizerResult.resultType == "MyKadFront result") { resultDiv.innerHTML = /** Personal information */ "ID Type: " + fields[kPPDataType] + "
" + @@ -340,6 +343,45 @@ scanButton.addEventListener('click', function() { "Religion: " + fields[kPPmyKadReligion] + "
" + "Sex: " + fields[kPPmyKadSex] + "
"; + } else if (recognizerResult.resultType == "MyKadBack result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "NRIC Number: " + fields[kPPmyKadNricNumber] + "
" + + "Extended NRIC Number: " + fields[kPPmyKadBackExtendedNricNumber] + "
" + + "Birth Date: " + fields[kPPmyKadBackBirthDate] + "
" + + "Sex: " + fields[kPPmyKadBackSex] + "
"; + + } else if (recognizerResult.resultType == "MyTentera result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "Army Number: " + fields[kPPmyTenteraArmyNumber] + "
" + + "NRIC Number: " + fields[kPPmyTenteraNricNumber] + "
" + + "Address: " + fields[kPPmyTenteraAddress] + "
" + + "Address ZIP Code: " + fields[kPPmyTenteraAddressZipCode] + "
" + + "Address Street: " + fields[kPPmyTenteraAddressStreet] + "
" + + "Address City: " + fields[kPPmyTenteraAddressCity] + "
" + + "Address State: " + fields[kPPmyTenteraAddressState] + "
" + + "Birth Date: " + fields[kPPmyTenteraBirthDate] + "
" + + "Full Name: " + fields[kPPmyTenteraFullName] + "
" + + "Religion: " + fields[kPPmyTenteraReligion] + "
" + + "Sex: " + fields[kPPmyTenteraSex] + "
"; + + } else if (recognizerResult.resultType == "IKad result") { + + resultDiv.innerHTML = /** Personal information */ + "ID Type: " + fields[kPPDataType] + "
" + + "Address: " + fields[kPPiKadAddress] + "
" + + "Birth Date: " + fields[kPPiKadDateOfBirth] + "
" + + "Employer: " + fields[kPPiKadEmployer] + "
" + + "Expiry Date: " + fields[kPPiKadExpiryDate] + "
" + + "Name: " + fields[kPPiKadName] + "
" + + "Nationality: " + fields[kPPiKadNationality] + "
" + + "Passport Number: " + fields[kPPiKadPassportNumber] + "
" + + "Sector: " + fields[kPPiKadSector] + "
" + + "Sex: " + fields[kPPiKadSex] + "
"; + } else if (recognizerResult.resultType == "GermanOldID result") { resultDiv.innerHTML = /** Personal information */ @@ -417,7 +459,7 @@ scanButton.addEventListener('click', function() { "Date of issue: " + fields[kPPsingaporeDateOfIssue] + "
" + "Blood group: " + fields[kPPsingaporeBloodGroup] + "
" + "Address: " + fields[kPPsingaporeAddress] + "
"; - + } else if (recognizerResult.resultType == "DocumentDetector result") { resultDiv.innerHTML = "Found a document"; @@ -459,7 +501,7 @@ scanButton.addEventListener('click', function() { types, imageTypes, licenseiOs, licenseAndroid, language ); -});; +}); ``` + Available scanners are: @@ -470,7 +512,10 @@ scanButton.addEventListener('click', function() { + **EUDL** - scans the front of European driver's license + **UKDL** - scans the front of United Kingom driver's license + **DEDL** - scans the front of German driver's license - + **MyKad** - scans the front of Malaysian ID cards + + **MyKadFront** - scans the front side of Malaysian ID card + + **MyKadBack** - scans the back side of Malaysian ID card + + **IKad** - scans the front side of IKad card + + **MyTentera** - scans the front side of Malaysian Tentera card + **GermanOldID** - scans the front of old German ID cards + **GermanIDFront** - scans the front of German ID cards + **GermanIDBack** - scans the back of German ID cards From 157b25bf8edd5e74628f59c92d99fc79ea796784 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 10:34:45 +0200 Subject: [PATCH 15/18] Updated release notes --- Release notes.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Release notes.md b/Release notes.md index ccb1ab7..94eaf41 100644 --- a/Release notes.md +++ b/Release notes.md @@ -1,3 +1,16 @@ +## 1.5.1 +- renamed `MyKad` recognizer to `MyKadFront` +- updated iOS SDK to v2.16.1 +- added the following recognizers: + - `iKad` - scans the front of iKad cards + - `MyTentera` - scans the front of MyTentera cards + - `MyKadBack` - scans the back of MyKad cards + +## 1.5.0 +- added the following recognizers: + - `SingaporeIDFrontRecognizer` - scans the front of Singapore ID cards + - `SingaporeIDBackRecognizer` - scans the back of Singapore ID cards + ## 1.4.4 - added the following recognizers: - `UnitedArabEmiratesIDBack` - scans the back of United Arab Emirates ID cards From 52e82b21378cd579344973dfb10b1e5d7a379e70 Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 10:34:51 +0200 Subject: [PATCH 16/18] Version bump --- BlinkID/package.json | 2 +- BlinkID/plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BlinkID/package.json b/BlinkID/package.json index e51320c..28d4633 100644 --- a/BlinkID/package.json +++ b/BlinkID/package.json @@ -1,6 +1,6 @@ { "name": "blinkid", - "version": "1.5.0", + "version": "1.5.1", "description": "A small and powerful ID card scanning library", "cordova": { "id": "com.microblink.blinkid", diff --git a/BlinkID/plugin.xml b/BlinkID/plugin.xml index 782d4ea..407c0e6 100644 --- a/BlinkID/plugin.xml +++ b/BlinkID/plugin.xml @@ -2,7 +2,7 @@ + version="1.5.1"> BlinkIdScanner A small and powerful ID card scanning library From e4ee88922235f16c2e04e4a39886682035f4710f Mon Sep 17 00:00:00 2001 From: Jure Cular Date: Mon, 26 Mar 2018 11:03:57 +0200 Subject: [PATCH 17/18] Added comment for ikad sector key --- www/js/ikad_keys.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/js/ikad_keys.js b/www/js/ikad_keys.js index 7b5fa99..737406d 100644 --- a/www/js/ikad_keys.js +++ b/www/js/ikad_keys.js @@ -31,7 +31,9 @@ var kPPiKadNationality = "iKadNationality.Nationality"; var kPPiKadPassportNumber = "iKadPassportNumber.PassportNumber"; - +/* + Some iKad cards contain sector field, if they don't it won't be returned in the result dictionary. +*/ var kPPiKadSector = "iKadSector.Sector"; From 9db6c3c0bf95793147a0d11506812600111cfe4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Vidakovic=CC=81?= Date: Mon, 26 Mar 2018 14:18:04 +0200 Subject: [PATCH 18/18] [android] ikad fix - copying temp dob into standard dob field --- .../com/phonegap/plugins/blinkid/BlinkIdScanner.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java index 6a877c2..f0043d1 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/blinkid/BlinkIdScanner.java @@ -880,6 +880,18 @@ private JSONObject buildMyKadBackResult(MyKadBackSideRecognitionResult res) thro private JSONObject buildIkadResult(IKadRecognitionResult res) throws JSONException { JSONObject result = buildKeyValueResult(res, RecognizerType.IKAD.resultId); + + //copy temp dob to standard dob field + try { + JSONObject fields = result.getJSONObject("fields"); + Object tempDate = fields.get("iKadDateOfBirthTemp.DateOfBirth"); + if(tempDate != null) { + fields.put("iKadDateOfBirth.DateOfBirth", tempDate); + } + } catch (JSONException e) { + //ignore + } + putDocumentImageToResultJson(result, IKadRecognitionResult.class); putFaceImageToResultJson(result, IKadRecognitionResult.class); return result;