-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from BlinkID/release/v4.9.0
Release/v4.9.0
- Loading branch information
Showing
19 changed files
with
262 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...com/microblink/reactnative/recognizers/serialization/PassportRecognizerSerialization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
.../ios/MicroblinkModule/MicroblinkModule/Recognizers/Wrappers/MBPassportRecognizerWrapper.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
75 changes: 75 additions & 0 deletions
75
.../ios/MicroblinkModule/MicroblinkModule/Recognizers/Wrappers/MBPassportRecognizerWrapper.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters