Skip to content

Commit

Permalink
Merge pull request #112 from BlinkID/release/v4.9.0
Browse files Browse the repository at this point in the history
Release/v4.9.0
  • Loading branch information
i1E authored Apr 26, 2019
2 parents a5a126d + c8f9023 commit 175d2fd
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BlinkID/blinkid-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source_files = "src/ios", "src/ios/**/*.{h,m}"

s.dependency 'React'
s.dependency 'PPBlinkID', '~> 4.8.0'
s.dependency 'PPBlinkID', '~> 4.9.0'

s.frameworks = 'UIKit'
end
1 change: 1 addition & 0 deletions BlinkID/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export * from './recognizers/moroccoIdFrontRecognizer'
export * from './recognizers/mrtdCombinedRecognizer'
export * from './recognizers/mrtdRecognizer'
export * from './recognizers/newZealandDlFrontRecognizer'
export * from './recognizers/passportRecognizer'
export * from './recognizers/pdf417Recognizer'
export * from './recognizers/polandCombinedRecognizer'
export * from './recognizers/polandIdBackRecognizer'
Expand Down
2 changes: 1 addition & 1 deletion BlinkID/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blinkid-react-native",
"version": "4.8.0",
"version": "4.9.0",
"description": "A small and powerful ID card scanning library. Powered by Microblink (www.microblink.com).",
"main": "index.js",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions BlinkID/recognizers/documentFaceRecognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export class DocumentFaceRecognizer extends Recognizer {
*/
this.returnFullDocumentImage = false;

/**
* Setting for control over FaceImageCropProcessor's tryBothOrientations option
*
*
*/
this.tryBothOrientations = false;

this.createResultFromNative = function (nativeResult) { return new DocumentFaceRecognizerResult(nativeResult); }
}
}
5 changes: 5 additions & 0 deletions BlinkID/recognizers/germanyCombinedRecognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export class GermanyCombinedRecognizerResult extends RecognizerResult {
*/
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.
Expand Down
92 changes: 92 additions & 0 deletions BlinkID/recognizers/passportRecognizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Recognizer, RecognizerResult } from '../recognizer'
import {
Date,
Point,
Quadrilateral,
MrtdDocumentType,
MrzResult,
EudlCountry,
DocumentFaceDetectorType,
ImageExtensionFactors,
} from '../types'

/**
* Result object for PassportRecognizer.
*/
export class PassportRecognizerResult extends RecognizerResult {
constructor(nativeResult) {
super(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;

}
}

/**
* Recognizer which can scan all passports with MRZ.
*/
export class PassportRecognizer extends Recognizer {
constructor() {
super('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); }
}
}
2 changes: 1 addition & 1 deletion BlinkID/src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:28.0.0"
compile 'com.facebook.react:react-native:+'
compile('com.microblink:blinkid:4.8.0@aar') {
compile('com.microblink:blinkid:4.9.0@aar') {
transitive = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void registerMapping( RecognizerSerialization recognizerSerialization )
registerMapping(new MrtdCombinedRecognizerSerialization());
registerMapping(new MrtdRecognizerSerialization());
registerMapping(new NewZealandDlFrontRecognizerSerialization());
registerMapping(new PassportRecognizerSerialization());
registerMapping(new Pdf417RecognizerSerialization());
registerMapping(new PolandCombinedRecognizerSerialization());
registerMapping(new PolandIdBackRecognizerSerialization());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public final class DocumentFaceRecognizerSerialization implements RecognizerSeri
if (jsonRecognizer.hasKey("returnFullDocumentImage")) {
recognizer.setReturnFullDocumentImage(jsonRecognizer.getBoolean("returnFullDocumentImage"));
}
if (jsonRecognizer.hasKey("tryBothOrientations")) {
recognizer.setTryBothOrientations(jsonRecognizer.getBoolean("tryBothOrientations"));
}
return recognizer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public WritableMap serializeResult(Recognizer<?, ?> recognizer) {
jsonResult.putBoolean("mrzVerified", result.isMrzVerified());
jsonResult.putString("nationality", result.getNationality());
jsonResult.putString("placeOfBirth", result.getPlaceOfBirth());
jsonResult.putString("rawMrzString", result.getRawMrzString());
jsonResult.putBoolean("scanningFirstSideDone", result.isScanningFirstSideDone());
jsonResult.putString("sex", result.getSex());
jsonResult.putString("signatureImage", SerializationUtils.encodeImageBase64(result.getSignatureImage()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.microblink.reactnative.recognizers.serialization;

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.microblink.entities.recognizers.Recognizer;
import com.microblink.reactnative.recognizers.RecognizerSerialization;

public final class PassportRecognizerSerialization implements RecognizerSerialization {
@Override
public Recognizer<?, ?> createRecognizer(ReadableMap jsonRecognizer) {
com.microblink.entities.recognizers.blinkid.passport.PassportRecognizer recognizer = new com.microblink.entities.recognizers.blinkid.passport.PassportRecognizer();
if (jsonRecognizer.hasKey("detectGlare")) {
recognizer.setDetectGlare(jsonRecognizer.getBoolean("detectGlare"));
}
if (jsonRecognizer.hasKey("faceImageDpi")) {
recognizer.setFaceImageDpi(jsonRecognizer.getInt("faceImageDpi"));
}
if (jsonRecognizer.hasKey("fullDocumentImageDpi")) {
recognizer.setFullDocumentImageDpi(jsonRecognizer.getInt("fullDocumentImageDpi"));
}
if (jsonRecognizer.hasKey("fullDocumentImageExtensionFactors")) {
recognizer.setFullDocumentImageExtensionFactors(BlinkIDSerializationUtils.deserializeExtensionFactors(jsonRecognizer.getMap("fullDocumentImageExtensionFactors")));
}
if (jsonRecognizer.hasKey("returnFaceImage")) {
recognizer.setReturnFaceImage(jsonRecognizer.getBoolean("returnFaceImage"));
}
if (jsonRecognizer.hasKey("returnFullDocumentImage")) {
recognizer.setReturnFullDocumentImage(jsonRecognizer.getBoolean("returnFullDocumentImage"));
}
return recognizer;
}

@Override
public WritableMap serializeResult(Recognizer<?, ?> recognizer) {
com.microblink.entities.recognizers.blinkid.passport.PassportRecognizer.Result result = ((com.microblink.entities.recognizers.blinkid.passport.PassportRecognizer)recognizer).getResult();
WritableMap jsonResult = new WritableNativeMap();
SerializationUtils.addCommonResultData(jsonResult, result);
jsonResult.putString("faceImage", SerializationUtils.encodeImageBase64(result.getFaceImage()));
jsonResult.putString("fullDocumentImage", SerializationUtils.encodeImageBase64(result.getFullDocumentImage()));
jsonResult.putMap("mrzResult", BlinkIDSerializationUtils.serializeMrzResult(result.getMrzResult()));
return jsonResult;
}

@Override
public String getJsonName() {
return "PassportRecognizer";
}

@Override
public Class<?> getRecognizerClass() {
return com.microblink.entities.recognizers.blinkid.passport.PassportRecognizer.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import "MBRecognizerWrapper.h"
#import <MicroBlink/MicroBlink.h>

@interface MBPassportRecognizerCreator : NSObject<MBRecognizerCreator>

@end
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ react-native link blinkid-react-native
platform :ios, '9.0'

target 'TargetName' do
pod 'PPBlinkID', '~> 4.8.0'
pod 'PPBlinkID', '~> 4.9.0'
end
```

Expand Down
4 changes: 2 additions & 2 deletions demoApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {

const licenseKey = Platform.select({
// iOS license key for applicationID: org.reactjs.native.example.BlinkIDReactNative
ios: 'sRwAAAEtb3JnLnJlYWN0anMubmF0aXZlLmV4YW1wbGUuQmxpbmtJRFJlYWN0TmF0aXZlt67qu61k2vMma/KTrphwHMvoHXMjmoOiNv6uxnbg320lcJ/RpFYDaeHwCnSmYXWbcR16T+Sp3nqKT26WY/VGUzrsYfVP8V5wefOfy+IMnMT99E2wsW0ID3GfoZmyOYnhvE9jy66qJyVWb06spHnJ35MuaIL94ySwxwlSBmjaG0vs0Nz902P0tCMTlAgAUZVfacsBrBE3LsXWbO7bm3NbX52JDBYQjGENXT9ZP9oSTPcUOdggYpIM7fDDREdm',
ios: 'sRwAAAEtb3JnLnJlYWN0anMubmF0aXZlLmV4YW1wbGUuQmxpbmtJRFJlYWN0TmF0aXZlt67qu61k2vMma/KTqrh3HKRQDbpa74eiMGdAU9TqJMgdHe8dYsa02Qa29JwPUSSnRIYiNl5jlyhlsFnVizsvMO5LzE/aApMRC63SChp3/WRnzU8kDu5JO3vA7crY1YqrYs5H/QB6ZYjFVjS4orYcbfYet39uNE1uE4uAXmpAdDncB5KSbcVpu3pwZyMOkShi8dh3c+TnrpBTNp7xEEzakeIp9hR+VmeN6qIikNszTUzDjZLNhghptZ1wDsW/',
// android license key for applicationID: com.blinkidreactnative
android: 'sRwAAAAWY29tLmJsaW5raWRyZWFjdG5hdGl2ZYouOuuUS2CbdVuol25oyKRUaeMN2tXUUHsnmsYZFmU/Q4p3rKzxWcsyPbfyJOarHpp6DAV9+ZtOSJ3VPOp2DY0kN8cxu3JoD+ceI4wngSVkO0LNv9EcuHefI0C+hJ1v+g7FgF5MftcMGQhgt8W5Bvj+vsIWhtBKuVZgJJrbl1jC9/NvmXaua1RpQDZf81ycjJfZRFmSTnRQJexYdfEalCme3cjvxVs95WbROPBjAedixp5g35P7ohxQgBNj5A=='
android: 'sRwAAAAWY29tLmJsaW5raWRyZWFjdG5hdGl2ZYouOuuUS2CbdVuol2rYYA2v4YK/4PmyekYU/MSHvquNTqD1hDrtpzR337rQoTgQzZJXbzjPsVEGy+9OM/96qJDLAtYb92fGQcy5nYYMLO/hi+81+xpHrm8SmI5JmIUON1oB12O79TMZ64l0cNp1wAuqGUSam89PSNkeDH/9UkCiFiumaQIQf1WoTdfRx/WbpXNqIhe7vqhCtDKprlUY/ctdA43NAKcSBHUMdugsYGEbvw5s14lC1JEsl7Oy0Q=='
})

var renderIf = function(condition, content) {
Expand Down
4 changes: 2 additions & 2 deletions initReactNativeDemoApp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ else
# use directly source code from this repo instead of npm package
# from RN 0.57 symlink does not work any more
npm pack $blink_id_plugin_path
npm i --save blinkid-react-native-4.8.0.tgz
npm i --save blinkid-react-native-4.9.0.tgz
npm install
#pushd node_modules
#ln -s $blink_id_plugin_path blinkid-react-native
Expand Down Expand Up @@ -56,7 +56,7 @@ cat > Podfile << EOF
platform :ios, '8.0'
target 'BlinkIDReactNative' do
pod 'PPBlinkID', '~> 4.8.0'
pod 'PPBlinkID', '~> 4.9.0'
end
EOF

Expand Down

0 comments on commit 175d2fd

Please sign in to comment.