diff --git a/BlinkID/package.json b/BlinkID/package.json index c6f83e1..ab30846 100644 --- a/BlinkID/package.json +++ b/BlinkID/package.json @@ -1,6 +1,6 @@ { "name": "blinkid-cordova", - "version": "4.10.0", + "version": "4.11.0", "description": "A small and powerful ID card scanning library", "cordova": { "id": "blinkid-cordova", diff --git a/BlinkID/plugin.xml b/BlinkID/plugin.xml index 3beaa92..3929a50 100644 --- a/BlinkID/plugin.xml +++ b/BlinkID/plugin.xml @@ -2,7 +2,7 @@ + version="4.11.0"> BlinkIdScanner A small and powerful ID card scanning library @@ -80,6 +80,7 @@ + @@ -91,6 +92,7 @@ + @@ -118,6 +120,7 @@ + @@ -155,6 +158,7 @@ + @@ -219,6 +223,7 @@ + @@ -250,9 +255,11 @@ + + @@ -269,6 +276,7 @@ + @@ -303,6 +311,7 @@ + @@ -320,6 +329,7 @@ + @@ -357,6 +367,7 @@ + @@ -372,6 +383,7 @@ + diff --git a/BlinkID/scripts/initIOSFramework.sh b/BlinkID/scripts/initIOSFramework.sh index 8205df9..5507627 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.10.0/blinkid-ios_v4.10.0.zip' +LINK='https://github.com/BlinkID/blinkid-ios/releases/download/v4.11.0/blinkid-ios_v4.11.0.zip' FILENAME='blinkid-ios.zip' # check if Microblink framework and bundle already exist diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/MicroblinkScanner.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/MicroblinkScanner.java index f991f6b..a71df35 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/MicroblinkScanner.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/MicroblinkScanner.java @@ -13,8 +13,8 @@ import android.content.Intent; import com.microblink.MicroblinkSDK; -import com.microblink.intent.IntentDataTransferMode; import com.microblink.entities.recognizers.RecognizerBundle; +import com.microblink.intent.IntentDataTransferMode; import com.microblink.uisettings.UISettings; import com.phonegap.plugins.microblink.overlays.OverlaySettingsSerializers; import com.phonegap.plugins.microblink.recognizers.RecognizerSerializers; @@ -76,7 +76,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo setLicense(jsonLicenses); mRecognizerBundle = RecognizerSerializers.INSTANCE.deserializeRecognizerCollection(jsonRecognizerCollection); - UISettings overlaySettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(jsonOverlaySettings, mRecognizerBundle); + UISettings overlaySettings = OverlaySettingsSerializers.INSTANCE.getOverlaySettings(this.cordova.getContext(), jsonOverlaySettings, mRecognizerBundle); // unable to use ActivityRunner because we need to use cordova's activity launcher Intent intent = new Intent(this.cordova.getContext(), overlaySettings.getTargetActivity()); diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerialization.java index 0d7285d..f9cee3c 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerialization.java @@ -1,5 +1,7 @@ package com.phonegap.plugins.microblink.overlays; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle; import com.microblink.uisettings.UISettings; @@ -7,7 +9,7 @@ public interface OverlaySettingsSerialization { - UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle); + UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle); String getJsonName(); } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerializers.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerializers.java index b7e596a..0284cf7 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerializers.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/OverlaySettingsSerializers.java @@ -1,5 +1,6 @@ package com.phonegap.plugins.microblink.overlays; +import android.content.Context; import com.microblink.entities.recognizers.RecognizerBundle; import com.microblink.uisettings.UISettings; @@ -27,9 +28,9 @@ private void registerMapping(OverlaySettingsSerialization overlaySettingsSeriali registerMapping(new BlinkIdOverlaySettingsSerialization()); } - public UISettings getOverlaySettings(JSONObject jsonOverlaySettings, RecognizerBundle recognizerBundle) { + public UISettings getOverlaySettings(Context context, JSONObject jsonOverlaySettings, RecognizerBundle recognizerBundle) { try { - return mByJSONName.get(jsonOverlaySettings.getString("overlaySettingsType")).createUISettings(jsonOverlaySettings, recognizerBundle); + return mByJSONName.get(jsonOverlaySettings.getString("overlaySettingsType")).createUISettings(context, jsonOverlaySettings, recognizerBundle); } catch (JSONException e) { throw new RuntimeException(e); } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BarcodeOverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BarcodeOverlaySettingsSerialization.java index 9060569..5e70f68 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BarcodeOverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BarcodeOverlaySettingsSerialization.java @@ -1,5 +1,7 @@ package com.phonegap.plugins.microblink.overlays.serialization; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle; import com.microblink.uisettings.BarcodeUISettings; import com.microblink.uisettings.UISettings; @@ -9,7 +11,7 @@ public final class BarcodeOverlaySettingsSerialization implements OverlaySettingsSerialization { @Override - public UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { + public UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { // no settings deserialized at the moment return new BarcodeUISettings(recognizerBundle); } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkCardOverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkCardOverlaySettingsSerialization.java index 08e150d..af27933 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkCardOverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkCardOverlaySettingsSerialization.java @@ -1,6 +1,9 @@ package com.phonegap.plugins.microblink.overlays.serialization; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle; +import com.microblink.fragment.overlay.blinkcard.scanlineui.ScanLineOverlayStrings; import com.microblink.uisettings.BlinkCardUISettings; import com.microblink.uisettings.UISettings; import com.phonegap.plugins.microblink.overlays.OverlaySettingsSerialization; @@ -9,26 +12,28 @@ public final class BlinkCardOverlaySettingsSerialization implements OverlaySettingsSerialization { @Override - public UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { + public UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { BlinkCardUISettings settings = new BlinkCardUISettings(recognizerBundle); + ScanLineOverlayStrings.Builder overlayStringsBuilder = new ScanLineOverlayStrings.Builder(context); String firstSideInstructions = getStringFromJSONObject(jsonUISettings, "firstSideInstructions"); if (firstSideInstructions != null) { - settings.setFirstSideInstructions(firstSideInstructions); + overlayStringsBuilder.setFrontSideInstructions(firstSideInstructions); } String secondSideInstructions = getStringFromJSONObject(jsonUISettings, "secondSideInstructions"); if (secondSideInstructions != null) { - settings.setSecondSideInstructions(secondSideInstructions); + overlayStringsBuilder.setBackSideInstructions(secondSideInstructions); } + settings.setStrings(overlayStringsBuilder.build()); return settings; } private String getStringFromJSONObject(JSONObject map, String key) { - String value = map.optString(key, null); - if ("null".equals(value)) { - value = null; - } + String value = map.optString(key, null); + if ("null".equals(value)) { + value = null; + } return value; } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkIdOverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkIdOverlaySettingsSerialization.java index 1a8482a..f750a39 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkIdOverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/BlinkIdOverlaySettingsSerialization.java @@ -1,5 +1,7 @@ package com.phonegap.plugins.microblink.overlays.serialization; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle; import com.microblink.uisettings.BlinkIdUISettings; import com.microblink.uisettings.UISettings; @@ -9,7 +11,7 @@ public final class BlinkIdOverlaySettingsSerialization implements OverlaySettingsSerialization { @Override - public UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { + public UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { // no settings deserialized at the moment return new BlinkIdUISettings(recognizerBundle); } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentOverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentOverlaySettingsSerialization.java index 507ebf2..e1e43ab 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentOverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentOverlaySettingsSerialization.java @@ -1,5 +1,7 @@ package com.phonegap.plugins.microblink.overlays.serialization; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle;; import com.microblink.uisettings.DocumentUISettings; import com.microblink.uisettings.UISettings; @@ -9,7 +11,7 @@ public final class DocumentOverlaySettingsSerialization implements OverlaySettingsSerialization { @Override - public UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { + public UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { // no settings deserialized at the moment return new DocumentUISettings(recognizerBundle); } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentVerificationOverlaySettingsSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentVerificationOverlaySettingsSerialization.java index 023c922..05fb9ed 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentVerificationOverlaySettingsSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/overlays/serialization/DocumentVerificationOverlaySettingsSerialization.java @@ -1,6 +1,9 @@ package com.phonegap.plugins.microblink.overlays.serialization; +import android.content.Context; + import com.microblink.entities.recognizers.RecognizerBundle; +import com.microblink.fragment.overlay.blinkid.documentverification.DocumentVerificationOverlayStrings; import com.microblink.uisettings.DocumentVerificationUISettings; import com.microblink.uisettings.UISettings; import com.phonegap.plugins.microblink.overlays.OverlaySettingsSerialization; @@ -9,38 +12,40 @@ public final class DocumentVerificationOverlaySettingsSerialization implements OverlaySettingsSerialization { @Override - public UISettings createUISettings(JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { - DocumentVerificationUISettings settings = new DocumentVerificationUISettings(recognizerBundle); + public UISettings createUISettings(Context context, JSONObject jsonUISettings, RecognizerBundle recognizerBundle) { + DocumentVerificationUISettings settings = new DocumentVerificationUISettings(recognizerBundle); - String firstSideSplashMessage = getStringFromJSONObject(jsonUISettings, "firstSideSplashMessage"); + DocumentVerificationOverlayStrings.Builder overlasStringsBuilder = new DocumentVerificationOverlayStrings.Builder(context); + String firstSideSplashMessage = getStringFromJSONObject(jsonUISettings, "firstSideSplashMessage"); if (firstSideSplashMessage != null) { - settings.setFirstSideSplashMessage(firstSideSplashMessage); + overlasStringsBuilder.setFrontSideSplashText(firstSideSplashMessage); } String secondSideSplashMessage = getStringFromJSONObject(jsonUISettings, "secondSideSplashMessage"); if (secondSideSplashMessage != null) { - settings.setSecondSideSplashMessage(secondSideSplashMessage); + overlasStringsBuilder.setBackSideSplashText(secondSideSplashMessage); } String firstSideInstructions = getStringFromJSONObject(jsonUISettings, "firstSideInstructions"); if (firstSideInstructions != null) { - settings.setFirstSideInstructions(firstSideInstructions); + overlasStringsBuilder.setFrontSideInstructions(firstSideInstructions); } String secondSideInstructions = getStringFromJSONObject(jsonUISettings, "secondSideInstructions"); if (secondSideInstructions != null) { - settings.setSecondSideInstructions(secondSideInstructions); + overlasStringsBuilder.setBackSideInstructions(secondSideInstructions); } String glareMessage = getStringFromJSONObject(jsonUISettings, "glareMessage"); if (glareMessage != null) { - settings.setGlareMessage(glareMessage); + overlasStringsBuilder.setGlareMessage(glareMessage); } + settings.setStrings(overlasStringsBuilder.build()); return settings; } private String getStringFromJSONObject(JSONObject map, String key) { - String value = map.optString(key, null); - if ("null".equals(value)) { - value = null; - } + String value = map.optString(key, null); + if ("null".equals(value)) { + value = null; + } return value; } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/RecognizerSerializers.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/RecognizerSerializers.java index d1ef849..b1b3fd9 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/RecognizerSerializers.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/RecognizerSerializers.java @@ -31,6 +31,9 @@ private void registerMapping( RecognizerSerialization recognizerSerialization ) registerMapping(new AustriaIdFrontRecognizerSerialization()); registerMapping(new AustriaPassportRecognizerSerialization()); registerMapping(new BarcodeRecognizerSerialization()); + registerMapping(new BelgiumCombinedRecognizerSerialization()); + registerMapping(new BelgiumIdBackRecognizerSerialization()); + registerMapping(new BelgiumIdFrontRecognizerSerialization()); registerMapping(new BlinkCardEliteRecognizerSerialization()); registerMapping(new BlinkCardRecognizerSerialization()); registerMapping(new BlinkIdCombinedRecognizerSerialization()); @@ -117,6 +120,7 @@ private void registerMapping( RecognizerSerialization recognizerSerialization ) registerMapping(new UnitedArabEmiratesIdBackRecognizerSerialization()); registerMapping(new UnitedArabEmiratesIdFrontRecognizerSerialization()); registerMapping(new VinRecognizerSerialization()); + registerMapping(new VisaRecognizerSerialization()); registerMapping(new UsdlRecognizerSerialization()); registerMapping(new UsdlCombinedRecognizerSerialization()); diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumCombinedRecognizerSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumCombinedRecognizerSerialization.java new file mode 100644 index 0000000..6fe6edb --- /dev/null +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumCombinedRecognizerSerialization.java @@ -0,0 +1,62 @@ +package com.phonegap.plugins.microblink.recognizers.serialization; + +import com.microblink.entities.recognizers.Recognizer; +import com.phonegap.plugins.microblink.recognizers.RecognizerSerialization; + +import org.json.JSONException; +import org.json.JSONObject; + +public final class BelgiumCombinedRecognizerSerialization implements RecognizerSerialization { + + @Override + public Recognizer createRecognizer(JSONObject jsonRecognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumCombinedRecognizer recognizer = new com.microblink.entities.recognizers.blinkid.belgium.BelgiumCombinedRecognizer(); + recognizer.setDetectGlare(jsonRecognizer.optBoolean("detectGlare", true)); + recognizer.setFaceImageDpi(jsonRecognizer.optInt("faceImageDpi", 250)); + recognizer.setFullDocumentImageDpi(jsonRecognizer.optInt("fullDocumentImageDpi", 250)); + recognizer.setFullDocumentImageExtensionFactors(BlinkIDSerializationUtils.deserializeExtensionFactors(jsonRecognizer.optJSONObject("fullDocumentImageExtensionFactors"))); + recognizer.setReturnFaceImage(jsonRecognizer.optBoolean("returnFaceImage", false)); + recognizer.setReturnFullDocumentImage(jsonRecognizer.optBoolean("returnFullDocumentImage", false)); + recognizer.setSignResult(jsonRecognizer.optBoolean("signResult", false)); + return recognizer; + } + + @Override + public JSONObject serializeResult(Recognizer recognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumCombinedRecognizer.Result result = ((com.microblink.entities.recognizers.blinkid.belgium.BelgiumCombinedRecognizer)recognizer).getResult(); + JSONObject jsonResult = new JSONObject(); + try { + SerializationUtils.addCommonResultData(jsonResult, result); + jsonResult.put("cardNumber", result.getCardNumber()); + jsonResult.put("dateOfBirth", SerializationUtils.serializeDate(result.getDateOfBirth())); + jsonResult.put("dateOfExpiry", SerializationUtils.serializeDate(result.getDateOfExpiry())); + jsonResult.put("digitalSignature", SerializationUtils.encodeByteArrayToBase64(result.getDigitalSignature())); + jsonResult.put("digitalSignatureVersion", (int)result.getDigitalSignatureVersion()); + jsonResult.put("documentDataMatch", result.isDocumentDataMatch()); + jsonResult.put("faceImage", SerializationUtils.encodeImageBase64(result.getFaceImage())); + jsonResult.put("firstName", result.getFirstName()); + jsonResult.put("fullDocumentBackImage", SerializationUtils.encodeImageBase64(result.getFullDocumentBackImage())); + jsonResult.put("fullDocumentFrontImage", SerializationUtils.encodeImageBase64(result.getFullDocumentFrontImage())); + jsonResult.put("issuedBy", result.getIssuedBy()); + jsonResult.put("lastName", result.getLastName()); + jsonResult.put("mrzVerified", result.isMrzVerified()); + jsonResult.put("nationality", result.getNationality()); + jsonResult.put("scanningFirstSideDone", result.isScanningFirstSideDone()); + jsonResult.put("sex", result.getSex()); + } catch (JSONException e) { + // see https://developer.android.com/reference/org/json/JSONException + throw new RuntimeException(e); + } + return jsonResult; + } + + @Override + public String getJsonName() { + return "BelgiumCombinedRecognizer"; + } + + @Override + public Class getRecognizerClass() { + return com.microblink.entities.recognizers.blinkid.belgium.BelgiumCombinedRecognizer.class; + } +} \ No newline at end of file diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdBackRecognizerSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdBackRecognizerSerialization.java new file mode 100644 index 0000000..d6c88ec --- /dev/null +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdBackRecognizerSerialization.java @@ -0,0 +1,45 @@ +package com.phonegap.plugins.microblink.recognizers.serialization; + +import com.microblink.entities.recognizers.Recognizer; +import com.phonegap.plugins.microblink.recognizers.RecognizerSerialization; + +import org.json.JSONException; +import org.json.JSONObject; + +public final class BelgiumIdBackRecognizerSerialization implements RecognizerSerialization { + + @Override + public Recognizer createRecognizer(JSONObject jsonRecognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdBackRecognizer recognizer = new com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdBackRecognizer(); + recognizer.setDetectGlare(jsonRecognizer.optBoolean("detectGlare", true)); + recognizer.setFullDocumentImageDpi(jsonRecognizer.optInt("fullDocumentImageDpi", 250)); + recognizer.setFullDocumentImageExtensionFactors(BlinkIDSerializationUtils.deserializeExtensionFactors(jsonRecognizer.optJSONObject("fullDocumentImageExtensionFactors"))); + recognizer.setReturnFullDocumentImage(jsonRecognizer.optBoolean("returnFullDocumentImage", false)); + return recognizer; + } + + @Override + public JSONObject serializeResult(Recognizer recognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdBackRecognizer.Result result = ((com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdBackRecognizer)recognizer).getResult(); + JSONObject jsonResult = new JSONObject(); + try { + SerializationUtils.addCommonResultData(jsonResult, result); + jsonResult.put("fullDocumentImage", SerializationUtils.encodeImageBase64(result.getFullDocumentImage())); + jsonResult.put("mrzResult", BlinkIDSerializationUtils.serializeMrzResult(result.getMrzResult())); + } catch (JSONException e) { + // see https://developer.android.com/reference/org/json/JSONException + throw new RuntimeException(e); + } + return jsonResult; + } + + @Override + public String getJsonName() { + return "BelgiumIdBackRecognizer"; + } + + @Override + public Class getRecognizerClass() { + return com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdBackRecognizer.class; + } +} \ No newline at end of file diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdFrontRecognizerSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdFrontRecognizerSerialization.java new file mode 100644 index 0000000..a53c889 --- /dev/null +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/BelgiumIdFrontRecognizerSerialization.java @@ -0,0 +1,48 @@ +package com.phonegap.plugins.microblink.recognizers.serialization; + +import com.microblink.entities.recognizers.Recognizer; +import com.phonegap.plugins.microblink.recognizers.RecognizerSerialization; + +import org.json.JSONException; +import org.json.JSONObject; + +public final class BelgiumIdFrontRecognizerSerialization implements RecognizerSerialization { + + @Override + public Recognizer createRecognizer(JSONObject jsonRecognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdFrontRecognizer recognizer = new com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdFrontRecognizer(); + recognizer.setDetectGlare(jsonRecognizer.optBoolean("detectGlare", true)); + recognizer.setFaceImageDpi(jsonRecognizer.optInt("faceImageDpi", 250)); + recognizer.setFullDocumentImageDpi(jsonRecognizer.optInt("fullDocumentImageDpi", 250)); + recognizer.setFullDocumentImageExtensionFactors(BlinkIDSerializationUtils.deserializeExtensionFactors(jsonRecognizer.optJSONObject("fullDocumentImageExtensionFactors"))); + recognizer.setReturnFaceImage(jsonRecognizer.optBoolean("returnFaceImage", false)); + recognizer.setReturnFullDocumentImage(jsonRecognizer.optBoolean("returnFullDocumentImage", false)); + return recognizer; + } + + @Override + public JSONObject serializeResult(Recognizer recognizer) { + com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdFrontRecognizer.Result result = ((com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdFrontRecognizer)recognizer).getResult(); + JSONObject jsonResult = new JSONObject(); + try { + SerializationUtils.addCommonResultData(jsonResult, result); + jsonResult.put("cardNumber", result.getCardNumber()); + jsonResult.put("faceImage", SerializationUtils.encodeImageBase64(result.getFaceImage())); + jsonResult.put("fullDocumentImage", SerializationUtils.encodeImageBase64(result.getFullDocumentImage())); + } catch (JSONException e) { + // see https://developer.android.com/reference/org/json/JSONException + throw new RuntimeException(e); + } + return jsonResult; + } + + @Override + public String getJsonName() { + return "BelgiumIdFrontRecognizer"; + } + + @Override + public Class getRecognizerClass() { + return com.microblink.entities.recognizers.blinkid.belgium.BelgiumIdFrontRecognizer.class; + } +} \ No newline at end of file diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/DocumentFaceRecognizerSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/DocumentFaceRecognizerSerialization.java index 7a88dc5..45c2250 100644 --- a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/DocumentFaceRecognizerSerialization.java +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/DocumentFaceRecognizerSerialization.java @@ -18,7 +18,6 @@ public Recognizer createRecognizer(JSONObject jsonRecognizer) { recognizer.setNumStableDetectionsThreshold(jsonRecognizer.optInt("numStableDetectionsThreshold", 6)); recognizer.setReturnFaceImage(jsonRecognizer.optBoolean("returnFaceImage", false)); recognizer.setReturnFullDocumentImage(jsonRecognizer.optBoolean("returnFullDocumentImage", false)); - recognizer.setTryBothOrientations(jsonRecognizer.optBoolean("tryBothOrientations", true)); return recognizer; } diff --git a/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/VisaRecognizerSerialization.java b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/VisaRecognizerSerialization.java new file mode 100644 index 0000000..035164e --- /dev/null +++ b/BlinkID/src/android/java/com/phonegap/plugins/microblink/recognizers/serialization/VisaRecognizerSerialization.java @@ -0,0 +1,48 @@ +package com.phonegap.plugins.microblink.recognizers.serialization; + +import com.microblink.entities.recognizers.Recognizer; +import com.phonegap.plugins.microblink.recognizers.RecognizerSerialization; + +import org.json.JSONException; +import org.json.JSONObject; + +public final class VisaRecognizerSerialization implements RecognizerSerialization { + + @Override + public Recognizer createRecognizer(JSONObject jsonRecognizer) { + com.microblink.entities.recognizers.blinkid.visa.VisaRecognizer recognizer = new com.microblink.entities.recognizers.blinkid.visa.VisaRecognizer(); + recognizer.setDetectGlare(jsonRecognizer.optBoolean("detectGlare", true)); + recognizer.setFaceImageDpi(jsonRecognizer.optInt("faceImageDpi", 250)); + recognizer.setFullDocumentImageDpi(jsonRecognizer.optInt("fullDocumentImageDpi", 250)); + recognizer.setFullDocumentImageExtensionFactors(BlinkIDSerializationUtils.deserializeExtensionFactors(jsonRecognizer.optJSONObject("fullDocumentImageExtensionFactors"))); + recognizer.setReturnFaceImage(jsonRecognizer.optBoolean("returnFaceImage", false)); + recognizer.setReturnFullDocumentImage(jsonRecognizer.optBoolean("returnFullDocumentImage", false)); + return recognizer; + } + + @Override + public JSONObject serializeResult(Recognizer recognizer) { + com.microblink.entities.recognizers.blinkid.visa.VisaRecognizer.Result result = ((com.microblink.entities.recognizers.blinkid.visa.VisaRecognizer)recognizer).getResult(); + JSONObject jsonResult = new JSONObject(); + try { + SerializationUtils.addCommonResultData(jsonResult, result); + jsonResult.put("faceImage", SerializationUtils.encodeImageBase64(result.getFaceImage())); + jsonResult.put("fullDocumentImage", SerializationUtils.encodeImageBase64(result.getFullDocumentImage())); + jsonResult.put("mrzResult", BlinkIDSerializationUtils.serializeMrzResult(result.getMrzResult())); + } catch (JSONException e) { + // see https://developer.android.com/reference/org/json/JSONException + throw new RuntimeException(e); + } + return jsonResult; + } + + @Override + public String getJsonName() { + return "VisaRecognizer"; + } + + @Override + public Class getRecognizerClass() { + return com.microblink.entities.recognizers.blinkid.visa.VisaRecognizer.class; + } +} \ No newline at end of file diff --git a/BlinkID/src/android/libBlinkID.gradle b/BlinkID/src/android/libBlinkID.gradle index 241f416..f020494 100644 --- a/BlinkID/src/android/libBlinkID.gradle +++ b/BlinkID/src/android/libBlinkID.gradle @@ -5,7 +5,7 @@ repositories { } dependencies { - implementation('com.microblink:blinkid:4.10.0@aar') { + implementation('com.microblink:blinkid:4.11.0@aar') { transitive = true } } diff --git a/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m b/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m index 1539bf8..3287de1 100644 --- a/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m +++ b/BlinkID/src/ios/sources/Recognizers/MBRecognizerSerializers.m @@ -10,6 +10,9 @@ #import "MBAustriaIdFrontRecognizerWrapper.h" #import "MBAustriaPassportRecognizerWrapper.h" #import "MBBarcodeRecognizerWrapper.h" +#import "MBBelgiumCombinedRecognizerWrapper.h" +#import "MBBelgiumIdBackRecognizerWrapper.h" +#import "MBBelgiumIdFrontRecognizerWrapper.h" #import "MBBlinkCardEliteRecognizerWrapper.h" #import "MBBlinkCardRecognizerWrapper.h" #import "MBBlinkIdCombinedRecognizerWrapper.h" @@ -96,6 +99,7 @@ #import "MBUnitedArabEmiratesIdBackRecognizerWrapper.h" #import "MBUnitedArabEmiratesIdFrontRecognizerWrapper.h" #import "MBVinRecognizerWrapper.h" +#import "MBVisaRecognizerWrapper.h" #import "MBUsdlRecognizerWrapper.h" #import "MBUsdlCombinedRecognizerWrapper.h" @@ -125,6 +129,9 @@ - (instancetype)init { [self registerCreator:[[MBAustriaIdFrontRecognizerCreator alloc] init]]; [self registerCreator:[[MBAustriaPassportRecognizerCreator alloc] init]]; [self registerCreator:[[MBBarcodeRecognizerCreator alloc] init]]; + [self registerCreator:[[MBBelgiumCombinedRecognizerCreator alloc] init]]; + [self registerCreator:[[MBBelgiumIdBackRecognizerCreator alloc] init]]; + [self registerCreator:[[MBBelgiumIdFrontRecognizerCreator alloc] init]]; [self registerCreator:[[MBBlinkCardEliteRecognizerCreator alloc] init]]; [self registerCreator:[[MBBlinkCardRecognizerCreator alloc] init]]; [self registerCreator:[[MBBlinkIdCombinedRecognizerCreator alloc] init]]; @@ -211,6 +218,7 @@ - (instancetype)init { [self registerCreator:[[MBUnitedArabEmiratesIdBackRecognizerCreator alloc] init]]; [self registerCreator:[[MBUnitedArabEmiratesIdFrontRecognizerCreator alloc] init]]; [self registerCreator:[[MBVinRecognizerCreator alloc] init]]; + [self registerCreator:[[MBVisaRecognizerCreator alloc] init]]; [self registerCreator:[[MBUsdlRecognizerCreator alloc] init]]; [self registerCreator:[[MBUsdlCombinedRecognizerCreator alloc] init]]; diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.h b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.h new file mode 100644 index 0000000..38db895 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.h @@ -0,0 +1,6 @@ +#import "MBRecognizerWrapper.h" +#import + +@interface MBBelgiumCombinedRecognizerCreator : NSObject + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.m new file mode 100644 index 0000000..09a37d2 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumCombinedRecognizerWrapper.m @@ -0,0 +1,94 @@ +#import "MBBelgiumCombinedRecognizerWrapper.h" +#import "MBSerializationUtils.h" +#import "MBBlinkIDSerializationUtils.h" + +@implementation MBBelgiumCombinedRecognizerCreator + +@synthesize jsonName = _jsonName; + +-(instancetype) init { + self = [super init]; + if (self) { + _jsonName = @"BelgiumCombinedRecognizer"; + } + return self; +} + +-(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { + MBBelgiumCombinedRecognizer *recognizer = [[MBBelgiumCombinedRecognizer 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]; + } + } + { + id signResult = [jsonRecognizer valueForKey:@"signResult"]; + if (signResult != nil) { + recognizer.signResult = [(NSNumber *)signResult boolValue]; + } + } + + return recognizer; +} + +@end + +@interface MBBelgiumCombinedRecognizer (JsonSerialization) +@end + +@implementation MBBelgiumCombinedRecognizer (JsonSerialization) + +-(NSDictionary *) serializeResult { + NSMutableDictionary* jsonResult = (NSMutableDictionary*)[super serializeResult]; + [jsonResult setValue:self.result.cardNumber forKey:@"cardNumber"]; + [jsonResult setValue:[MBSerializationUtils serializeMBDateResult:self.result.dateOfBirth] forKey:@"dateOfBirth"]; + [jsonResult setValue:[MBSerializationUtils serializeMBDateResult:self.result.dateOfExpiry] forKey:@"dateOfExpiry"]; + [jsonResult setValue:[self.result.digitalSignature base64EncodedStringWithOptions:0] forKey:@"digitalSignature"]; + [jsonResult setValue:[NSNumber numberWithUnsignedInteger:self.result.digitalSignatureVersion] forKey:@"digitalSignatureVersion"]; + [jsonResult setValue:[NSNumber numberWithBool:self.result.documentDataMatch] forKey:@"documentDataMatch"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.faceImage] forKey:@"faceImage"]; + [jsonResult setValue:self.result.firstName forKey:@"firstName"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.fullDocumentBackImage] forKey:@"fullDocumentBackImage"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.fullDocumentFrontImage] forKey:@"fullDocumentFrontImage"]; + [jsonResult setValue:self.result.issuedBy forKey:@"issuedBy"]; + [jsonResult setValue:self.result.lastName forKey:@"lastName"]; + [jsonResult setValue:[NSNumber numberWithBool:self.result.mrzVerified] forKey:@"mrzVerified"]; + [jsonResult setValue:self.result.nationality forKey:@"nationality"]; + [jsonResult setValue:[NSNumber numberWithBool:self.result.scanningFirstSideDone] forKey:@"scanningFirstSideDone"]; + [jsonResult setValue:self.result.sex forKey:@"sex"]; + + return jsonResult; +} + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.h b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.h new file mode 100644 index 0000000..ab58bac --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.h @@ -0,0 +1,6 @@ +#import "MBRecognizerWrapper.h" +#import + +@interface MBBelgiumIdBackRecognizerCreator : NSObject + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.m new file mode 100644 index 0000000..04a2cab --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdBackRecognizerWrapper.m @@ -0,0 +1,62 @@ +#import "MBBelgiumIdBackRecognizerWrapper.h" +#import "MBSerializationUtils.h" +#import "MBBlinkIDSerializationUtils.h" + +@implementation MBBelgiumIdBackRecognizerCreator + +@synthesize jsonName = _jsonName; + +-(instancetype) init { + self = [super init]; + if (self) { + _jsonName = @"BelgiumIdBackRecognizer"; + } + return self; +} + +-(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { + MBBelgiumIdBackRecognizer *recognizer = [[MBBelgiumIdBackRecognizer alloc] init]; + { + id detectGlare = [jsonRecognizer valueForKey:@"detectGlare"]; + if (detectGlare != nil) { + recognizer.detectGlare = [(NSNumber *)detectGlare boolValue]; + } + } + { + 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 returnFullDocumentImage = [jsonRecognizer valueForKey:@"returnFullDocumentImage"]; + if (returnFullDocumentImage != nil) { + recognizer.returnFullDocumentImage = [(NSNumber *)returnFullDocumentImage boolValue]; + } + } + + return recognizer; +} + +@end + +@interface MBBelgiumIdBackRecognizer (JsonSerialization) +@end + +@implementation MBBelgiumIdBackRecognizer (JsonSerialization) + +-(NSDictionary *) serializeResult { + NSMutableDictionary* jsonResult = (NSMutableDictionary*)[super serializeResult]; + [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/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.h b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.h new file mode 100644 index 0000000..ce5ead5 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.h @@ -0,0 +1,6 @@ +#import "MBRecognizerWrapper.h" +#import + +@interface MBBelgiumIdFrontRecognizerCreator : NSObject + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.m new file mode 100644 index 0000000..041499f --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBBelgiumIdFrontRecognizerWrapper.m @@ -0,0 +1,75 @@ +#import "MBBelgiumIdFrontRecognizerWrapper.h" +#import "MBSerializationUtils.h" +#import "MBBlinkIDSerializationUtils.h" + +@implementation MBBelgiumIdFrontRecognizerCreator + +@synthesize jsonName = _jsonName; + +-(instancetype) init { + self = [super init]; + if (self) { + _jsonName = @"BelgiumIdFrontRecognizer"; + } + return self; +} + +-(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { + MBBelgiumIdFrontRecognizer *recognizer = [[MBBelgiumIdFrontRecognizer 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 MBBelgiumIdFrontRecognizer (JsonSerialization) +@end + +@implementation MBBelgiumIdFrontRecognizer (JsonSerialization) + +-(NSDictionary *) serializeResult { + NSMutableDictionary* jsonResult = (NSMutableDictionary*)[super serializeResult]; + [jsonResult setValue:self.result.cardNumber forKey:@"cardNumber"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.faceImage] forKey:@"faceImage"]; + [jsonResult setValue:[MBSerializationUtils encodeMBImage:self.result.fullDocumentImage] forKey:@"fullDocumentImage"]; + + return jsonResult; +} + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m index 5c399b8..c035c85 100644 --- a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBDocumentFaceRecognizerWrapper.m @@ -58,12 +58,6 @@ -(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/MBVisaRecognizerWrapper.h b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBVisaRecognizerWrapper.h new file mode 100644 index 0000000..903d5c1 --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBVisaRecognizerWrapper.h @@ -0,0 +1,6 @@ +#import "MBRecognizerWrapper.h" +#import + +@interface MBVisaRecognizerCreator : NSObject + +@end \ No newline at end of file diff --git a/BlinkID/src/ios/sources/Recognizers/Wrappers/MBVisaRecognizerWrapper.m b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBVisaRecognizerWrapper.m new file mode 100644 index 0000000..a78110a --- /dev/null +++ b/BlinkID/src/ios/sources/Recognizers/Wrappers/MBVisaRecognizerWrapper.m @@ -0,0 +1,75 @@ +#import "MBVisaRecognizerWrapper.h" +#import "MBSerializationUtils.h" +#import "MBBlinkIDSerializationUtils.h" + +@implementation MBVisaRecognizerCreator + +@synthesize jsonName = _jsonName; + +-(instancetype) init { + self = [super init]; + if (self) { + _jsonName = @"VisaRecognizer"; + } + return self; +} + +-(MBRecognizer *) createRecognizer:(NSDictionary*) jsonRecognizer { + MBVisaRecognizer *recognizer = [[MBVisaRecognizer 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 MBVisaRecognizer (JsonSerialization) +@end + +@implementation MBVisaRecognizer (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 0d8cf41..497e8e3 100644 --- a/BlinkID/www/blinkIdScanner.js +++ b/BlinkID/www/blinkIdScanner.js @@ -2089,6 +2089,320 @@ BarcodeRecognizer.prototype = new Recognizer('BarcodeRecognizer'); BlinkID.prototype.BarcodeRecognizer = BarcodeRecognizer; +/** + * Result object for BelgiumCombinedRecognizer. + */ +function BelgiumCombinedRecognizerResult(nativeResult) { + RecognizerResult.call(this, nativeResult.resultState); + + /** + * The card number of the Belgium ID card. + */ + this.cardNumber = nativeResult.cardNumber; + + /** + * The date of birth of the Belgium ID owner. + */ + this.dateOfBirth = nativeResult.dateOfBirth != null ? new Date(nativeResult.dateOfBirth) : null; + + /** + * The date of expiry of the Belgium ID card. + */ + this.dateOfExpiry = nativeResult.dateOfExpiry != null ? new Date(nativeResult.dateOfExpiry) : null; + + /** + * Digital signature of the recognition result. Available only if enabled with signResult property. + */ + this.digitalSignature = nativeResult.digitalSignature; + + /** + * Version of the digital signature. Available only if enabled with signResult property. + */ + this.digitalSignatureVersion = nativeResult.digitalSignatureVersion; + + /** + * Returns true if data from scanned parts/sides of the document match, + * false otherwise. For example if date of expiry is scanned from the front and back side + * of the document and values do not match, this method will return false. Result will + * be true only if scanned values for all fields that are compared are the same. + */ + this.documentDataMatch = nativeResult.documentDataMatch; + + /** + * face image from the document if enabled with returnFaceImage property. + */ + this.faceImage = nativeResult.faceImage; + + /** + * The first name of the Belgium ID owner. + */ + this.firstName = nativeResult.firstName; + + /** + * back side image of the document if enabled with returnFullDocumentImage property. + */ + this.fullDocumentBackImage = nativeResult.fullDocumentBackImage; + + /** + * front side image of the document if enabled with returnFullDocumentImage property. + */ + this.fullDocumentFrontImage = nativeResult.fullDocumentFrontImage; + + /** + * The issuing authority of the Belgium ID card. + */ + this.issuedBy = nativeResult.issuedBy; + + /** + * The last name of the Belgium ID owner. + */ + this.lastName = nativeResult.lastName; + + /** + * Determines if all check digits inside MRZ are correct. + */ + this.mrzVerified = nativeResult.mrzVerified; + + /** + * The nationality of the Belgium ID owner. + */ + this.nationality = nativeResult.nationality; + + /** + * Returns true if recognizer has finished scanning first side and is now scanning back side, + * false if it's still scanning first side. + */ + this.scanningFirstSideDone = nativeResult.scanningFirstSideDone; + + /** + * The sex of the Belgium ID owner. + */ + this.sex = nativeResult.sex; + +} + +BelgiumCombinedRecognizerResult.prototype = new RecognizerResult(RecognizerResultState.empty); + +BlinkID.prototype.BelgiumCombinedRecognizerResult = BelgiumCombinedRecognizerResult; + +/** + * Recognizer which can scan front and back side of Belgium national ID cards. + */ +function BelgiumCombinedRecognizer() { + Recognizer.call(this, 'BelgiumCombinedRecognizer'); + + /** + * 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; + + /** + * Whether or not recognition result should be signed. + * + * + */ + this.signResult = false; + + this.createResultFromNative = function (nativeResult) { return new BelgiumCombinedRecognizerResult(nativeResult); } + +} + +BelgiumCombinedRecognizer.prototype = new Recognizer('BelgiumCombinedRecognizer'); + +BlinkID.prototype.BelgiumCombinedRecognizer = BelgiumCombinedRecognizer; + +/** + * Result object for BelgiumIdBackRecognizer. + */ +function BelgiumIdBackRecognizerResult(nativeResult) { + RecognizerResult.call(this, nativeResult.resultState); + + /** + * 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; + +} + +BelgiumIdBackRecognizerResult.prototype = new RecognizerResult(RecognizerResultState.empty); + +BlinkID.prototype.BelgiumIdBackRecognizerResult = BelgiumIdBackRecognizerResult; + +/** + * Recognizer which can scan back side of Belgium ID cards. + */ +function BelgiumIdBackRecognizer() { + Recognizer.call(this, 'BelgiumIdBackRecognizer'); + + /** + * Defines if glare detection should be turned on/off. + * + * + */ + this.detectGlare = true; + + /** + * 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 full document image of ID card should be extracted. + * + * + */ + this.returnFullDocumentImage = false; + + this.createResultFromNative = function (nativeResult) { return new BelgiumIdBackRecognizerResult(nativeResult); } + +} + +BelgiumIdBackRecognizer.prototype = new Recognizer('BelgiumIdBackRecognizer'); + +BlinkID.prototype.BelgiumIdBackRecognizer = BelgiumIdBackRecognizer; + +/** + * Result object for BelgiumIdFrontRecognizer. + */ +function BelgiumIdFrontRecognizerResult(nativeResult) { + RecognizerResult.call(this, nativeResult.resultState); + + /** + * The card number of the Belgium ID card. + */ + this.cardNumber = nativeResult.cardNumber; + + /** + * 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; + +} + +BelgiumIdFrontRecognizerResult.prototype = new RecognizerResult(RecognizerResultState.empty); + +BlinkID.prototype.BelgiumIdFrontRecognizerResult = BelgiumIdFrontRecognizerResult; + +/** + * Recognizer which can scan front side of Belgium national ID card. + */ +function BelgiumIdFrontRecognizer() { + Recognizer.call(this, 'BelgiumIdFrontRecognizer'); + + /** + * 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 BelgiumIdFrontRecognizerResult(nativeResult); } + +} + +BelgiumIdFrontRecognizer.prototype = new Recognizer('BelgiumIdFrontRecognizer'); + +BlinkID.prototype.BelgiumIdFrontRecognizer = BelgiumIdFrontRecognizer; + /** * Result object for BlinkCardEliteRecognizer. */ @@ -5660,13 +5974,6 @@ function DocumentFaceRecognizer() { */ this.returnFullDocumentImage = false; - /** - * Setting for control over FaceImageCropProcessor's tryBothOrientations option - * - * - */ - this.tryBothOrientations = false; - this.createResultFromNative = function (nativeResult) { return new DocumentFaceRecognizerResult(nativeResult); } } @@ -14956,6 +15263,92 @@ VinRecognizer.prototype = new Recognizer('VinRecognizer'); BlinkID.prototype.VinRecognizer = VinRecognizer; +/** + * Result object for VisaRecognizer. + */ +function VisaRecognizerResult(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; + +} + +VisaRecognizerResult.prototype = new RecognizerResult(RecognizerResultState.empty); + +BlinkID.prototype.VisaRecognizerResult = VisaRecognizerResult; + +/** + * Recognizer which can scan all visas with MRZ. + */ +function VisaRecognizer() { + Recognizer.call(this, 'VisaRecognizer'); + + /** + * 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 VisaRecognizerResult(nativeResult); } + +} + +VisaRecognizer.prototype = new Recognizer('VisaRecognizer'); + +BlinkID.prototype.VisaRecognizer = VisaRecognizer; + BlinkID.prototype.UsdlKeys = Object.freeze( { //==============================================================/ diff --git a/README.md b/README.md index 7093f2d..99d1965 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ cd testcordova cordova plugin add ../blinkid-phonegap/BlinkID # or just 'blinkid-cordova' if you don't have blinkid-phonegap locally # add android support to the project -cordova platform add android@7 +cordova platform add android@8 # build the project, the binary will appear in the bin/ folder cordova build android diff --git a/Release notes.md b/Release notes.md index a26db14..45a541a 100644 --- a/Release notes.md +++ b/Release notes.md @@ -1,3 +1,6 @@ +## 4.11.0 +- Updated to [Android SDK v4.11.0](https://github.com/BlinkID/blinkid-android/releases/tag/v4.11.0) and [iOS SDK v4.11.0](https://github.com/BlinkID/blinkid-ios/releases/tag/v4.11.0) + ## 4.10.0 - Updated to [Android SDK v4.10.0](https://github.com/BlinkID/blinkid-android/releases/tag/v4.10.0) and [iOS SDK v4.10.0](https://github.com/BlinkID/blinkid-ios/releases/tag/v4.10.0) diff --git a/www/js/index.js b/www/js/index.js index 1757258..79286e4 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -82,8 +82,8 @@ var app = { // package name/bundleID com.microblink.blinkid var licenseKeys = { - android: 'sRwAAAAWY29tLm1pY3JvYmxpbmsuYmxpbmtpZJ9ew00uWSf86/ux5PMILDweFVtiSUuS9RpUrbS9T3sxyqumJNvZZhmynJpMO4OuGMKlnucFqJ64Z48OKBDe0QEY85+CL6lcNBEuAENW3uLPzXzhwBllRcQfayC7S31nJs70sVYw1F0kodv04h+X1FJnG+fpX36GpLpVjWLzB7rqadCwwD/F/q1syNgg5CV4BwvBMFZPVy37c/GLNJofkla743XEZcu7BkFmOpc8z+iJjhumShIkRj+kxkj1PIliYWdf', - ios: 'sRwAAAEWY29tLm1pY3JvYmxpbmsuYmxpbmtpZFG2rW9X4lA0y++ptb7JSX2pZqBhfkJPY+Nc73d/DXvmJjYPpTI9gs1bIZClQM9Tb2XiaTCaSdwRGrUcroJtcUOUKa6IHo8HvMtCHNCBeKscEWsdsJvxax5+Y21iThnttfy6B86tarhF1rZgnA6Af3AjihUTr59jBS1b5MGU39PWPXyMYkN12NvvNTOA89f/T0K+f4czxmdFn//edElIemomdeqyBb1OYZXfSirvxPJ1ErU9TuPoSs0Ub8MhRm4VDFtM' + android: 'sRwAAAAWY29tLm1pY3JvYmxpbmsuYmxpbmtpZJ9ew00uWSf86/ux5PdQApJLUPzlGZQQniC8pjz/86XhMJztb5SZMedvP2uWZiyPE3zStafCO++dkPZAyb511hRVtSC3FJ5bGH/CQaXQLXpkMElVJRqO54iThgexIWWow3SVUWRySCSj8My/IpnXgmRUg9XrNUzy2475z8XR6omoX+pe0jfdmqeuV/2u5/WnjfOgx+W6Z83e80BfcX1k/1DixHlKAstcJl+D6vH4cRde+WAcTADiR0StcG0sN8EM3EO8', + ios: 'sRwAAAEWY29tLm1pY3JvYmxpbmsuYmxpbmtpZFG2rW9X4lA0y++ptboR69ypRSJvTVDmZZWdCfGEKT2PSYI2e6goCTXvROwYexCNWL3Ew5HzJwdKs0ugrPpKvGqOG4iiF+yrTCplrislVppjfV6v1NFN3y3b053kMcZwZFnL2dVTg5cfF2nkep2LoCsBF+eSG1u6c0uWITOTv96UzBZljFNLsokRGLtMQoN0V4WsrXCIzzhDgt0xbBHQWSW1QDFKAT9CiJ9qbljtk5UwjqLvDUMW372IPybPYco7D2zR' }; scanButton.addEventListener('click', function() {