From 772f65d237d5037c4725c7ab24b5fe4fa8636e3b Mon Sep 17 00:00:00 2001 From: Jura Skrlec Date: Thu, 25 Apr 2019 13:34:14 +0200 Subject: [PATCH] [ios] updated bindings for v4.9.0 --- BlinkID/plugin.xml | 2 + BlinkID/scripts/initIOSFramework.sh | 2 +- .../Recognizers/MBRecognizerSerializers.m | 2 + .../MBDocumentFaceRecognizerWrapper.m | 6 ++ .../MBGermanyCombinedRecognizerWrapper.m | 1 + .../Wrappers/MBPassportRecognizerWrapper.h | 6 ++ .../Wrappers/MBPassportRecognizerWrapper.m | 75 ++++++++++++++ BlinkID/www/blinkIdScanner.js | 98 +++++++++++++++++++ www/js/index.js | 2 +- 9 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.h create mode 100644 BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.m diff --git a/BlinkID/plugin.xml b/BlinkID/plugin.xml index 753b23e..23f48fc 100644 --- a/BlinkID/plugin.xml +++ b/BlinkID/plugin.xml @@ -270,6 +270,7 @@ + @@ -381,6 +382,7 @@ + diff --git a/BlinkID/scripts/initIOSFramework.sh b/BlinkID/scripts/initIOSFramework.sh index 93d25e3..e36ba37 100755 --- a/BlinkID/scripts/initIOSFramework.sh +++ b/BlinkID/scripts/initIOSFramework.sh @@ -4,7 +4,7 @@ HERE="$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")" pushd "${HERE}/../src/ios/" > /dev/null -LINK='https://github.com/BlinkID/blinkid-ios/releases/download/v4.8.0/blinkid-ios_v4.8.0.zip' +LINK='https://github.com/BlinkID/blinkid-ios/releases/download/v4.9.0/blinkid-ios_v4.9.0.zip' FILENAME='blinkid-ios.zip' # check if Microblink framework and bundle already exist diff --git a/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m b/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m index 5622693..874f0b7 100644 --- a/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m +++ b/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m @@ -65,6 +65,7 @@ #import "MBMrtdCombinedRecognizerWrapper.h" #import "MBMrtdRecognizerWrapper.h" #import "MBNewZealandDlFrontRecognizerWrapper.h" +#import "MBPassportRecognizerWrapper.h" #import "MBPdf417RecognizerWrapper.h" #import "MBPolandCombinedRecognizerWrapper.h" #import "MBPolandIdBackRecognizerWrapper.h" @@ -176,6 +177,7 @@ - (instancetype)init { [self registerCreator:[[MBMrtdCombinedRecognizerCreator alloc] init]]; [self registerCreator:[[MBMrtdRecognizerCreator alloc] init]]; [self registerCreator:[[MBNewZealandDlFrontRecognizerCreator alloc] init]]; + [self registerCreator:[[MBPassportRecognizerCreator alloc] init]]; [self registerCreator:[[MBPdf417RecognizerCreator alloc] init]]; [self registerCreator:[[MBPolandCombinedRecognizerCreator alloc] init]]; [self registerCreator:[[MBPolandIdBackRecognizerCreator alloc] init]]; diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m index c035c85..5c399b8 100644 --- a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m @@ -58,6 +58,12 @@ -(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { recognizer.returnFullDocumentImage = [(NSNumber *)returnFullDocumentImage boolValue]; } } + { + id tryBothOrientations = [jsonRecognizer valueForKey:@"tryBothOrientations"]; + if (tryBothOrientations != nil) { + recognizer.tryBothOrientations = [(NSNumber *)tryBothOrientations boolValue]; + } + } return recognizer; } diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBGermanyCombinedRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBGermanyCombinedRecognizerWrapper.m index 59ab08b..e85e15c 100644 --- a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBGermanyCombinedRecognizerWrapper.m +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBGermanyCombinedRecognizerWrapper.m @@ -180,6 +180,7 @@ -(NSDictionary *) serializeResult { [jsonResult setValue:[NSNumber numberWithBool:self.result.mrzVerified] forKey:@"mrzVerified"]; [jsonResult setValue:self.result.nationality forKey:@"nationality"]; [jsonResult setValue:self.result.placeOfBirth forKey:@"placeOfBirth"]; + [jsonResult setValue:self.result.rawMrzString forKey:@"rawMrzString"]; [jsonResult setValue:[NSNumber numberWithBool:self.result.scanningFirstSideDone] forKey:@"scanningFirstSideDone"]; [jsonResult setValue:self.result.sex forKey:@"sex"]; [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.signatureImage] forKey:@"signatureImage"]; diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.h b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.h new file mode 100644 index 0000000..ac28fc5 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.h @@ -0,0 +1,6 @@ +#import "MBRecognizerWrapper.h" +#import + +@interface MBPassportRecognizerCreator : NSObject + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.m new file mode 100644 index 0000000..a33d7f2 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBPassportRecognizerWrapper.m @@ -0,0 +1,75 @@ +#import "MBPassportRecognizerWrapper.h" +#import "MBSerializationUtils.h" +#import "MBBlinkIDSerializationUtils.h" + +@implementation MBPassportRecognizerCreator + +@synthesize jsonName = _jsonName; + +-(instancetype) init { + self = [super init]; + if (self) { + _jsonName = @"PassportRecognizer"; + } + return self; +} + +-(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { + MBPassportRecognizer *recognizer = [[MBPassportRecognizer alloc] init]; + { + id detectGlare = [jsonRecognizer valueForKey:@"detectGlare"]; + if (detectGlare != nil) { + recognizer.detectGlare = [(NSNumber *)detectGlare boolValue]; + } + } + { + id faceImageDpi = [jsonRecognizer valueForKey:@"faceImageDpi"]; + if (faceImageDpi != nil) { + recognizer.faceImageDpi = [(NSNumber *)faceImageDpi unsignedIntegerValue]; + } + } + { + id fullDocumentImageDpi = [jsonRecognizer valueForKey:@"fullDocumentImageDpi"]; + if (fullDocumentImageDpi != nil) { + recognizer.fullDocumentImageDpi = [(NSNumber *)fullDocumentImageDpi unsignedIntegerValue]; + } + } + { + id fullDocumentImageExtensionFactors = [jsonRecognizer valueForKey:@"fullDocumentImageExtensionFactors"]; + if (fullDocumentImageExtensionFactors != nil) { + recognizer.fullDocumentImageExtensionFactors = [MBBlinkIDSerializationUtils deserializeMBImageExtensionFactors:(NSDictionary*)fullDocumentImageExtensionFactors]; + } + } + { + id returnFaceImage = [jsonRecognizer valueForKey:@"returnFaceImage"]; + if (returnFaceImage != nil) { + recognizer.returnFaceImage = [(NSNumber *)returnFaceImage boolValue]; + } + } + { + id returnFullDocumentImage = [jsonRecognizer valueForKey:@"returnFullDocumentImage"]; + if (returnFullDocumentImage != nil) { + recognizer.returnFullDocumentImage = [(NSNumber *)returnFullDocumentImage boolValue]; + } + } + + return recognizer; +} + +@end + +@interface MBPassportRecognizer (JsonSerialization) +@end + +@implementation MBPassportRecognizer (JsonSerialization) + +-(NSDictionary *) serializeResult { + NSMutableDictionary* jsonResult = (NSMutableDictionary*)[super serializeResult]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.faceImage] forKey:@"faceImage"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.fullDocumentImage] forKey:@"fullDocumentImage"]; + [jsonResult setValue:[MBBlinkIDSerializationUtils serializeMrzResult:self.result.mrzResult] forKey:@"mrzResult"]; + + return jsonResult; +} + +@end \ No newline at end of file diff --git a/BlinkID/www/blinkIdScanner.js b/BlinkID/www/blinkIdScanner.js index e3c2c96..cfdeedc 100644 --- a/BlinkID/www/blinkIdScanner.js +++ b/BlinkID/www/blinkIdScanner.js @@ -5369,6 +5369,13 @@ function DocumentFaceRecognizer() { */ this.returnFullDocumentImage = false; + /** + * Setting for control over FaceImageCropProcessor's tryBothOrientations option + * + * + */ + this.tryBothOrientations = false; + this.createResultFromNative = function (nativeResult) { return new DocumentFaceRecognizerResult(nativeResult); } } @@ -5747,6 +5754,11 @@ function GermanyCombinedRecognizerResult(nativeResult) { */ this.placeOfBirth = nativeResult.placeOfBirth; + /** + * The full mrz string result. + */ + this.rawMrzString = nativeResult.rawMrzString; + /** * Returns true if recognizer has finished scanning first side and is now scanning back side, * false if it's still scanning first side. @@ -10344,6 +10356,92 @@ NewZealandDlFrontRecognizer.prototype = new Recognizer('NewZealandDlFrontRecogni BlinkID.prototype.NewZealandDlFrontRecognizer = NewZealandDlFrontRecognizer; +/** + * Result object for PassportRecognizer. + */ +function PassportRecognizerResult(nativeResult) { + RecognizerResult.call(this, nativeResult.resultState); + + /** + * face image from the document if enabled with returnFaceImage property. + */ + this.faceImage = nativeResult.faceImage; + + /** + * full document image if enabled with returnFullDocumentImage property. + */ + this.fullDocumentImage = nativeResult.fullDocumentImage; + + /** + * The data extracted from the machine readable zone. + */ + this.mrzResult = nativeResult.mrzResult != null ? new MrzResult(nativeResult.mrzResult) : null; + +} + +PassportRecognizerResult.prototype = new RecognizerResult(RecognizerResultState.empty); + +BlinkID.prototype.PassportRecognizerResult = PassportRecognizerResult; + +/** + * Recognizer which can scan all passports with MRZ. + */ +function PassportRecognizer() { + Recognizer.call(this, 'PassportRecognizer'); + + /** + * Defines if glare detection should be turned on/off. + * + * + */ + this.detectGlare = true; + + /** + * Property for setting DPI for face images + * Valid ranges are [100,400]. Setting DPI out of valid ranges throws an exception + * + * + */ + this.faceImageDpi = 250; + + /** + * Property for setting DPI for full document images + * Valid ranges are [100,400]. Setting DPI out of valid ranges throws an exception + * + * + */ + this.fullDocumentImageDpi = 250; + + /** + * Image extension factors for full document image. + * + * @see ImageExtensionFactors + * + */ + this.fullDocumentImageExtensionFactors = new ImageExtensionFactors(); + + /** + * Sets whether face image from ID card should be extracted + * + * + */ + this.returnFaceImage = false; + + /** + * Sets whether full document image of ID card should be extracted. + * + * + */ + this.returnFullDocumentImage = false; + + this.createResultFromNative = function (nativeResult) { return new PassportRecognizerResult(nativeResult); } + +} + +PassportRecognizer.prototype = new Recognizer('PassportRecognizer'); + +BlinkID.prototype.PassportRecognizer = PassportRecognizer; + /** * Result object for Pdf417Recognizer. */ diff --git a/www/js/index.js b/www/js/index.js index 7b1d094..fcbc38b 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -83,7 +83,7 @@ var app = { // package name/bundleID com.microblink.blinkid var licenseKeys = { android: 'sRwAAAAWY29tLm1pY3JvYmxpbmsuYmxpbmtpZJ9ew00uWSf86/ux5PGYgpVxe8daSAIioOFooMH1zSjCtUFYDv9AqV87Ew8fx8H/ag2O5/E1nN18stdwBpBjEvyG+tOKGyUYC3WecONS+6edT6mBfhwXh11Qgkn/eMeip1ep/k/tMcs4IPI6xLzevdpUY8YLwcWAlBGoCmYo6ijxrnKXcRck2FpXUdZedgOH0mRtTrSyT40DBjuA6O11rYPnCX1phzsobd2S71qVLoZ+zHg+60e3ePigLxIKiA==', - ios: 'sRwAAAEWY29tLm1pY3JvYmxpbmsuYmxpbmtpZFG2rW9X4lA0y++ptby56tjjJxcwi2w3o+JAeNhIYMY5L6BLVFWcAs12PilSay+gzrckE5oqyLvoz+/3OetjSSfjR69q2W0pmm23dX2IvFUqw5VNK1MGgcauw6wGsDFKyD5T8YJv6bRz180DRH/XZaRbP6AajJ8vD+BpRN08dckzZP6xE+9BQwtMJFKY3Y9uSCJx42LII8SblOZVe2x2awwIGwrXcMGMQsqpcBCDx8Hq9s83augQ2bpgn0uKow==' + ios: 'sRwAAAEWY29tLm1pY3JvYmxpbmsuYmxpbmtpZFG2rW9X4lA0y++ptbiZ7dj1E80ExjC//oFNqdO1aP3BzyX/8qAoWiV5mCPgIIDWRIXc2UdU0OrG+6/mEPb2u6EGhxMIXonSGsd8WICdxSV+baMRJck21qyZoCgRwz+eC0MXrTaPt1jqWVKHjYT7BvPaC8p+EV8RY6Vph89PLKDZxsvxM93HVFB7cah4xN12S6gNrtm25aIMEbpBInI40zmtpCBGoU8KR3U21A8spXVHZyGcGsG3guOSsqpsNg==' }; scanButton.addEventListener('click', function() {