Skip to content

Commit

Permalink
Merge pull request #31 from blinkcard/release/v2.8.0
Browse files Browse the repository at this point in the history
Release/v2.8.0
  • Loading branch information
krizaa authored Aug 22, 2023
2 parents fdd1afc + 205bea8 commit a6e8de8
Show file tree
Hide file tree
Showing 43 changed files with 3,990 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum ResultSource {

MIXED,
NONEMPTY,
FRONT,
BACK,
MRZ,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package com.microblink.blinkcard.result.activity.fragment;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;

import androidx.appcompat.widget.AppCompatSpinner;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.microblink.blinkcard.libutils.R;
import com.microblink.blinkcard.locale.LanguageUtils;
Expand Down Expand Up @@ -50,6 +56,29 @@ public void onAttach(Context context) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_results, container, false);
mListView = view.findViewById(R.id.list_view);
if (getActivity() != null) {
ClipboardManager clipboard = (ClipboardManager)
getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View child, int pos, long id) {
RecognitionResultEntry resultEntry = (RecognitionResultEntry) parent.getItemAtPosition(pos);
if (resultEntry != null) {
if (!resultEntry.getValue().equals("")) {
ClipData clip = ClipData.newPlainText(resultEntry.getKey(), resultEntry.getValue());
clipboard.setPrimaryClip(clip);
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S) {
Toast.makeText(
container.getContext(),
"Copied to clipboard",
Toast.LENGTH_SHORT
).show();
}
}
}
});
}
resultTypeSection = view.findViewById(R.id.result_type_section);
resultTypeSpinner = view.findViewById(R.id.result_type_spinner);
return view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected void add(int key, int value, String valueSuffix) {
}

protected void add(int key, Date date) {
mExtractedData.add(mBuilder.build(key, date != null ? date.getDate() : null));
mExtractedData.add(mBuilder.build(key, date != null ? date.getDate() : null, date.isFilledByDomainKnowledge()));
}

protected void addIfNotEmpty(int key, Date dateResult) {
Expand All @@ -75,8 +75,8 @@ protected void addIfNotEmpty(int key, Date dateResult) {
}
}

protected void add(int key, SimpleDate date) {
mExtractedData.add(mBuilder.build(key, date));
protected void add(int key, SimpleDate date, boolean isFilledByDomainKnowledge) {
mExtractedData.add(mBuilder.build(key, date, isFilledByDomainKnowledge));
}

protected void add(int key, boolean value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public RecognitionResultEntry build(@StringRes int key, Date value) {
if (value == null) {
return new RecognitionResultEntry(createKey(key), "");
} else {
return build(key, value.getDate());
return build(key, value.getDate(), value.isFilledByDomainKnowledge());
}
}

public RecognitionResultEntry build(@StringRes int key, SimpleDate value) {
public RecognitionResultEntry build(@StringRes int key, SimpleDate value, boolean isFilledByDomainKnowledge) {
String strVal = "";
if (value != null) {
Calendar cal = GregorianCalendar.getInstance();
Expand All @@ -112,6 +112,9 @@ public RecognitionResultEntry build(@StringRes int key, SimpleDate value) {
SimpleDateFormat df = new SimpleDateFormat(dateFormat.toString());
strVal = df.format(cal.getTime());
}
if(isFilledByDomainKnowledge) {
strVal += " (domain knowledge)";
}
return new RecognitionResultEntry(createKey(key), strVal);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.microblink.blinkcard.result.extract.blinkcard;

import com.microblink.blinkcard.entities.recognizers.blinkcard.BlinkCardRecognizer;
import com.microblink.blinkcard.entities.recognizers.blinkcard.DocumentLivenessCheckResult;
import com.microblink.blinkcard.image.Image;
import com.microblink.blinkcard.libutils.R;
import com.microblink.blinkcard.result.extract.BaseResultExtractor;
import com.microblink.blinkcard.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

public class BlinkCardRecognizerResultExtractor extends BaseResultExtractor<BlinkCardRecognizer.Result, BlinkCardRecognizer> {

Expand All @@ -17,6 +22,9 @@ protected void extractData(BlinkCardRecognizer.Result result) {
add(R.string.PPDateOfExpiry, result.getExpiryDate());
add(R.string.PPCVV, result.getCvv());
add(R.string.PPIBAN, result.getIban());
add(R.string.first_side_anonymized, result.isFirstSideAnonymized());
add(R.string.second_side_anonymized, result.isSecondSideAnonymized());
addDocumentLivenessCheck(result.getDocumentLivenessCheck());

Image firstSideImage = result.getFirstSideFullDocumentImage();
if (firstSideImage != null) {
Expand All @@ -35,5 +43,35 @@ protected void extractData(BlinkCardRecognizer.Result result) {
}
}

private void addDocumentLivenessCheck(DocumentLivenessCheckResult documentLivenessCheckResult) {
JSONObject root = new JSONObject();
JSONObject front = new JSONObject();
JSONObject back = new JSONObject();
try {
front.put("frontScreenCheckResult", documentLivenessCheckResult.getFront().getScreenCheck().getCheckResult().name());
front.put("frontScreenCheckMatchLevel", documentLivenessCheckResult.getFront().getScreenCheck().getMatchLevel().name());

front.put("frontPhotocopyCheckResult", documentLivenessCheckResult.getFront().getPhotocopyCheck().getCheckResult().name());
front.put("frontPhotocopyCheckMatchLevel", documentLivenessCheckResult.getFront().getPhotocopyCheck().getMatchLevel().name());

front.put("handPresenceCheck", documentLivenessCheckResult.getFront().getHandPresenceCheck().name());
root.put("front", front);

back.put("backScreenCheckResult", documentLivenessCheckResult.getBack().getScreenCheck().getCheckResult().name());
back.put("backScreenCheckMatchLevel", documentLivenessCheckResult.getBack().getScreenCheck().getMatchLevel().name());

back.put("backPhotocopyCheckResult", documentLivenessCheckResult.getBack().getPhotocopyCheck().getCheckResult().name());
back.put("backPhotocopyCheckMatchLevel", documentLivenessCheckResult.getBack().getPhotocopyCheck().getMatchLevel().name());

back.put("handPresenceCheck", documentLivenessCheckResult.getBack().getHandPresenceCheck().name());
root.put("back", back);

add(R.string.document_liveness_check, root.toString(2));

} catch (JSONException e) {
Log.d(this, "Exception creating DocumentLivenessCheckResult!" + e.getMessage());
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:translateY="22.68">
<path
android:pathData="M604.548,125.826L683.117,321.911C686.444,330.199 688.102,339.062 687.995,347.993C687.895,356.923 686.031,365.746 682.51,373.955L599.367,568.212C595.858,576.413 590.768,583.842 584.387,590.075C578.007,596.308 570.461,601.223 562.181,604.54L366.03,683.123C357.748,686.445 348.894,688.096 339.972,687.996C331.05,687.889 322.235,686.032 314.033,682.517L119.773,599.359C103.214,592.268 90.147,578.893 83.443,562.174L4.876,366.025C1.557,357.746 -0.099,348.894 0.005,339.975C0.108,331.056 1.969,322.244 5.48,314.044L88.624,119.771C95.716,103.213 109.092,90.147 125.811,83.443L321.961,4.876C330.244,1.556 339.1,-0.099 348.022,0.005C356.944,0.108 365.758,1.969 373.96,5.48L568.219,88.624C576.422,92.134 583.853,97.225 590.087,103.609C596.321,109.993 601.234,117.542 604.548,125.826ZM491.539,478.572C506.652,470.796 523.138,462.315 541.221,452.409C571.017,436.168 592.693,408.087 598.192,382.406C604.231,356.472 594.028,332.952 573.56,320.048C526.827,290.114 507.633,252.812 478.6,196.39C470.827,181.284 462.349,164.808 452.449,146.736C436.287,116.924 408.207,95.216 382.526,89.765C356.591,83.711 333.071,93.929 320.167,114.397C290.238,161.119 252.947,180.305 196.544,209.322C181.429,217.099 164.94,225.582 146.852,235.49C117.04,251.747 95.347,279.827 89.88,305.508C83.841,331.427 94.044,354.963 114.512,367.85C161.245,397.785 180.439,435.086 209.472,491.509C217.244,506.615 225.722,523.091 235.622,541.162C251.784,570.975 279.865,592.683 305.546,598.134C331.481,604.188 355.001,593.986 367.905,573.517C397.835,526.78 435.131,507.593 491.539,478.572Z"
android:fillColor="#142641"
android:fillType="evenOdd"/>
android:fillColor="#142641"/>
</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@
<string name="PPPrimaryId">Primary ID</string>
<string name="PPSecondaryId">Secondary ID</string>
<string name="PPDateOfBirth">Date of birth</string>
<string name="PPDateOfBirthOriginal">Date of birth (original format)</string>
<string name="PPAge">Age</string>
<string name="PPDateOfExpiry">Date of Expiry</string>
<string name="PPDateOfExpiryOriginal">Date of Expiry (original format)</string>
<string name="PPDateOfExpiryPermanent">Date of Expiry Permanent</string>
<string name="PPExpired">Expired</string>
<string name="PPDocumentCode">Document code</string>
Expand Down Expand Up @@ -153,6 +155,7 @@
<string name="PPPlaceOfOrigin">Place of origin</string>
<string name="PPPlaceOfIssue">Place of issue</string>
<string name="PPIssueDate">Date of issuance</string>
<string name="PPIssueDateOriginal">Date of issuance (original format)</string>
<string name="PPDriverNumber">Driver number</string>
<string name="PPDetectorResult">Detector result</string>
<string name="PPFullName">Full name</string>
Expand Down Expand Up @@ -377,4 +380,9 @@

<string name="PPDateOfIssueDlCategoryB">Date of issue B category</string>
<string name="PPDateOfIssueDlCategoryBNotSpecified">Date of issue B category not specified</string>

<string name="filled_by_domain_knowledge">Filled by domain knowledge</string>
<string name="first_side_anonymized">First side anonymized</string>
<string name="second_side_anonymized">Second side anonymized</string>
<string name="document_liveness_check">Document liveness check</string>
</resources>
1 change: 1 addition & 0 deletions BlinkCardSample/LibUtils/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="result_type">Showing results extracted from: </string>
<string-array name="result_types">
<item>Mixed (best)</item>
<item>Mixed (non empty)</item>
<item>Front side OCR</item>
<item>Back side OCR</item>
<item>MRZ</item>
Expand Down
2 changes: 1 addition & 1 deletion BlinkCardSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ task clean(type: Delete) {
// versions of libraries that all modules require

project.ext {
blinkCardVersion = '2.7.0'
blinkCardVersion = '2.8.0'
compileSdkVersion = 31
targetSdkVersion = 31
appCompatVersion = '1.2.0'
Expand Down
Binary file modified LibBlinkCard-javadoc.jar
Binary file not shown.
Binary file modified LibBlinkCard.aar
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Add _BlinkCard_ as a dependency and make sure `transitive` is set to true

```
dependencies {
implementation('com.microblink:blinkcard:2.7.0@aar') {
implementation('com.microblink:blinkcard:2.8.0@aar') {
transitive = true
}
}
Expand All @@ -104,7 +104,7 @@ Android studio 3.0 should automatically import javadoc from maven dependency. If

1. In Android Studio project sidebar, ensure [project view is enabled](https://developer.android.com/sdk/installing/studio-androidview.html)
2. Expand `External Libraries` entry (usually this is the last entry in project view)
3. Locate `blinkcard-2.7.0` entry, right click on it and select `Library Properties...`
3. Locate `blinkcard-2.8.0` entry, right click on it and select `Library Properties...`
4. A `Library Properties` pop-up window will appear
5. Click the second `+` button in bottom left corner of the window (the one that contains `+` with little globe)
6. Window for defining documentation URL will appear
Expand Down
17 changes: 17 additions & 0 deletions Release notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Release notes

## 2.8.0

### Improvements
- Included hand, photocopy, and screen detection models to achieve liveness functionality
- Added anonymization info on which side was anonymized. String data is anonymized using an asterisk instead of blanking the result.
- Expanded the number of supported credit card types by 100%.
- Improved data extraction, including a 30% reduction in incorrect processing of CVV field.

### What's new in the BlinkCard Recognizer?
- Added new settings `handScaleThreshold`, `handDocumentOverlapThreshold`, `screenAnalysisMatchLevel`, `photocopyAnalysisMatchLevel`. These settings are used in combination with the new liveness features.
- Added a new callback `LivenessStatusCallback`, which is invoked when each side of a card is scanned. It is called with one parameter, a `LivenessStatus` enum. Use `BlinkCardRecognizer.setLivenessStatusCallback` method to set the callback.


### BlinkCard Recognizer Result
- Two new booleans: `firstSideAnonymized` and `secondSideAnonymized` have been added to indicate whether the first or second side of the card has been anonymized, respectively.
- New result documentLivenessCheck which has new liveness model results. It contains liveness information about the first and second sides of the card. Liveness information contains the results of checks performed on the card using screen detection, photocopy detection, and the presence of a live hand.

## 2.7.0

### New features:
Expand Down
2 changes: 1 addition & 1 deletion builtFromCommit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Built from commit e0390d6e620156bfe8e188f03056f737137ef5ff
Built from commit e212aa68138bcc9209970dae5946cf42b62e0a33
Loading

0 comments on commit a6e8de8

Please sign in to comment.