Skip to content

Commit

Permalink
Merge pull request #307 from BlinkID/release/v6.3.0
Browse files Browse the repository at this point in the history
Release/v6.3.0
  • Loading branch information
medvedecrobertmb authored Nov 3, 2023
2 parents 02c2f65 + 60eca54 commit 0f5b39b
Show file tree
Hide file tree
Showing 572 changed files with 87,145 additions and 189,225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.microblink.blinkid

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.microblink.blinkid.activity.result.ResultStatus
Expand All @@ -28,11 +29,11 @@ class MainActivity : AppCompatActivity() {
recognizerBundle = RecognizerBundle(recognizer)
}

fun onScanButtonClick() {
fun onScanButtonClick(view: View) {
// use default UI for scanning documents
val uiSettings = BlinkIdUISettings(recognizerBundle)

// start scan activity based on UI settings
// start scan activity based on UI setting
blinkIdScanLauncher.launch(uiSettings)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.locale.LanguageUtils;

public class HelpActivity extends FragmentActivity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public enum ResultSource {
FRONT,
BACK,
MRZ,
BARCODE

BARCODE,
LOCATIONS
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.microblink.blinkid.entities.recognizers.HighResImagesBundle;
import com.microblink.blinkid.image.Image;
import com.microblink.blinkid.image.highres.HighResImageWrapper;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.util.ImageUtils;

import androidx.annotation.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import android.widget.ListView;
import android.widget.Toast;

import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.locale.LanguageUtils;
import com.microblink.blinkid.result.extract.RecognitionResultEntry;

Expand Down Expand Up @@ -53,11 +53,11 @@ public void onAttach(Context context) {


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, final 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)
final ClipboardManager clipboard = (ClipboardManager)
getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.widget.ImageView;
import android.widget.TextView;

import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.result.extract.RecognitionResultEntry;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.microblink.blinkid.result.extract;

import android.content.Context;
import android.graphics.Bitmap;

import com.microblink.blinkid.entities.recognizers.Recognizer;
import com.microblink.blinkid.image.Image;
Expand Down Expand Up @@ -46,6 +47,9 @@ protected void onDataExtractionDone(ResultType result, ResultSource resultSource
protected void extractData(ResultType result, ResultSource resultSource) {
extractData(result);
}
protected void extractData(ResultType result, ResultSource resultSource, String jsonResult) {
extractData(result);
}

protected void add(int key, String value) {
mExtractedData.add(mBuilder.build(key, value));
Expand Down Expand Up @@ -95,5 +99,9 @@ protected void add(int key, Image image) {
mExtractedData.add(mBuilder.build(key, image));
}

protected void add(int key, Bitmap bitmap) {
mExtractedData.add(mBuilder.build(key, bitmap));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.text.TextUtils;

import com.microblink.blinkid.image.Image;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.results.date.Date;
import com.microblink.blinkid.results.date.SimpleDate;
import com.microblink.blinkid.util.ImageUtils;
Expand Down Expand Up @@ -153,5 +153,13 @@ public RecognitionResultEntry build(@StringRes int key, Image value) {
return new RecognitionResultEntry(createKey(key), ImageUtils.transformImage(value));
}
}

public RecognitionResultEntry build(@StringRes int key, Bitmap value) {
if ( value == null ) {
return build( key, "" );
} else {
return new RecognitionResultEntry(createKey(key), value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.microblink.blinkid.entities.recognizers.Recognizer;
import com.microblink.blinkid.entities.recognizers.successframe.SuccessFrameGrabberRecognizer;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.result.ResultSource;

public class SuccessFrameGrabberResultExtractor extends BaseResultExtractor<SuccessFrameGrabberRecognizer.Result, SuccessFrameGrabberRecognizer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@

package com.microblink.blinkid.result.extract.blinkid;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.microblink.blinkid.entities.recognizers.Recognizer;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.AlphabetType;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.DateResult;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.DriverLicenseDetailedInfo;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.Side;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.StringResult;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.VehicleClassInfo;
import com.microblink.blinkid.entities.recognizers.blinkid.generic.viz.VizResult;
import com.microblink.blinkid.entities.recognizers.blinkid.imageresult.EncodedFaceImageResult;
import com.microblink.blinkid.entities.recognizers.blinkid.imageresult.EncodedFullDocumentImageResult;
import com.microblink.blinkid.entities.recognizers.blinkid.imageresult.EncodedSignatureImageResult;
Expand All @@ -22,12 +31,17 @@
import com.microblink.blinkid.entities.recognizers.blinkid.imageresult.SignatureImageResult;
import com.microblink.blinkid.entities.recognizers.blinkid.mrtd.MrtdDocumentType;
import com.microblink.blinkid.entities.recognizers.blinkid.mrtd.MrzResult;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.result.extract.BaseResultExtractor;
import com.microblink.blinkid.result.extract.RecognitionResultEntry;
import com.microblink.blinkid.result.extract.util.images.CombinedFullDocumentImagesExtractUtil;
import com.microblink.blinkid.results.date.SimpleDate;
import com.microblink.blinkid.util.Log;

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

import java.util.ArrayList;
import java.util.List;

public abstract class BlinkIdExtractor<ResultType extends Recognizer.Result, RecognizerType extends Recognizer<ResultType>> extends BaseResultExtractor<ResultType, RecognizerType> {
Expand Down Expand Up @@ -124,6 +138,48 @@ protected void add(int key, StringResult value) {
mExtractedData.add(mBuilder.build(key, value != null ? value.toString() : null));
}

protected void addLocation(int key, StringResult value) {
if (value == null || value.value().isEmpty()) return;
try {
JSONObject root = new JSONObject();

if (!value.value(AlphabetType.Latin).isEmpty()) {
JSONObject latin = new JSONObject();

latin.put("value", value.value(AlphabetType.Latin));
latin.put("side", value.side(AlphabetType.Latin) != null ? value.side(AlphabetType.Latin) : "null");
latin.put("location", value.location(AlphabetType.Latin) != null ? value.location(AlphabetType.Latin).toString() : "null");
root.put("latin", latin);
}

if (!value.value(AlphabetType.Arabic).isEmpty()) {
JSONObject arabic = new JSONObject();
arabic.put("value", value.value(AlphabetType.Arabic));
arabic.put("side", value.side(AlphabetType.Arabic) != null ? value.side(AlphabetType.Arabic) : "null");
arabic.put("location", value.location(AlphabetType.Arabic) != null ? value.location(AlphabetType.Arabic).toString() : "null");
root.put("arabic", arabic);
}

if (!value.value(AlphabetType.Cyrillic).isEmpty()) {
JSONObject cyrilic = new JSONObject();
cyrilic.put("value", value.value(AlphabetType.Cyrillic));
cyrilic.put("side", value.side(AlphabetType.Cyrillic) != null ? value.side(AlphabetType.Cyrillic) : "null");
cyrilic.put("location", value.location(AlphabetType.Cyrillic) != null ? value.location(AlphabetType.Cyrillic).toString() : "null");
root.put("cyrilic", cyrilic);
}

add(key, root.toString(2).replaceAll("\\\\", ""));

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

protected void addLocation(int key, DateResult value) {
if (value == null) return;
addLocation(key, value.getOriginalDateString());
}

protected void addIfNotEmpty(int key, DateResult dateResult) {
if (dateResult == null) return;
SimpleDate date = dateResult.getDate();
Expand All @@ -138,4 +194,122 @@ protected void add(int key, DateResult date) {
mExtractedData.add(mBuilder.build(key, date != null ? date.getDate() : null, date != null ? date.isFilledByDomainKnowledge() : false));
}

protected void extractLocationsResultsFromVizResult(VizResult result) {
addLocation(R.string.PPFirstName, result.getFirstName());
addLocation(R.string.PPLastName, result.getLastName());
addLocation(R.string.PPFullName, result.getFullName());
addLocation(R.string.PPAdditionalNameInformation, result.getAdditionalNameInformation());
addLocation(R.string.PPLocalizedName, result.getLocalizedName());
addLocation(R.string.PPFatherName, result.getFathersName());
addLocation(R.string.PPMotherName, result.getMothersName());
addLocation(R.string.PPSex, result.getSex());

addLocation(R.string.PPAddress, result.getAddress());
addLocation(R.string.PPAdditionalAddressInformation, result.getAdditionalAddressInformation());
addLocation(R.string.PPAdditionalOptionalAddressInformation, result.getAdditionalOptionalAddressInformation());
addLocation(R.string.PPDateOfBirth, result.getDateOfBirth());

addLocation(R.string.PPIssueDate, result.getDateOfIssue());
addLocation(R.string.PPDateOfExpiry, result.getDateOfExpiry());

addLocation(R.string.PPPlaceOfBirth, result.getPlaceOfBirth());
addLocation(R.string.PPNationality, result.getNationality());

addLocation(R.string.PPRace, result.getRace());
addLocation(R.string.PPReligion, result.getReligion());
addLocation(R.string.PPProfession, result.getProfession());
addLocation(R.string.PPMaritalStatus, result.getMaritalStatus());
addLocation(R.string.PPResidentialStatus, result.getResidentialStatus());
addLocation(R.string.PPEmployer, result.getEmployer());

addLocation(R.string.PPDocumentNumber, result.getDocumentNumber());
addLocation(R.string.PPPersonalNumber, result.getPersonalIdNumber());
addLocation(R.string.PPDocumentAdditionalNumber, result.getDocumentAdditionalNumber());
addLocation(R.string.PPDocumentOptionalAdditionalNumber, result.getDocumentOptionalAdditionalNumber());
addLocation(R.string.PPPersonalAdditionalNumber, result.getAdditionalPersonalIdNumber());
addLocation(R.string.PPIssuingAuthority, result.getIssuingAuthority());
DriverLicenseDetailedInfo driverLicenseInfo = result.getDriverLicenseDetailedInfo();
if (!driverLicenseInfo.isEmpty()) {
addLocation(R.string.PPRestrictions, driverLicenseInfo.getRestrictions());
addLocation(R.string.PPConditions, driverLicenseInfo.getConditions());
addLocation(R.string.PPEndorsements, driverLicenseInfo.getEndorsements());
addLocation(R.string.PPVehicleClass, driverLicenseInfo.getVehicleClass());
for (VehicleClassInfo vehicleClassInfo : driverLicenseInfo.getVehicleClassesInfo()) {
addLocation(R.string.PPVehicleClass, vehicleClassInfo.getVehicleClass());
addLocation(R.string.PPLicenceType, vehicleClassInfo.getLicenceType());
addLocation(R.string.PPEffectiveDate, vehicleClassInfo.getEffectiveDate());
addLocation(R.string.PPDateOfExpiry, vehicleClassInfo.getExpiryDate());
}
}
}

protected List<StringResult> getAllStringResultsFromVizResult(VizResult result) {
List<StringResult> allStringResults = new ArrayList<>();
allStringResults.add(result.getFirstName());
allStringResults.add(result.getLastName());
allStringResults.add(result.getFullName());
allStringResults.add(result.getAdditionalNameInformation());
allStringResults.add(result.getLocalizedName());
allStringResults.add(result.getFathersName());
allStringResults.add(result.getMothersName());
allStringResults.add(result.getSex());

allStringResults.add(result.getAddress());
allStringResults.add(result.getAdditionalAddressInformation());
allStringResults.add(result.getAdditionalOptionalAddressInformation());

if (result.getDateOfBirth() != null) allStringResults.add(result.getDateOfBirth().getOriginalDateString());
if (result.getDateOfIssue() != null) allStringResults.add(result.getDateOfIssue().getOriginalDateString());
if (result.getDateOfExpiry() != null) allStringResults.add(result.getDateOfExpiry().getOriginalDateString());

allStringResults.add(result.getPlaceOfBirth());
allStringResults.add(result.getNationality());

allStringResults.add(result.getRace());
allStringResults.add(result.getReligion());
allStringResults.add(result.getProfession());
allStringResults.add(result.getMaritalStatus());
allStringResults.add(result.getResidentialStatus());
allStringResults.add(result.getEmployer());

allStringResults.add(result.getDocumentNumber());
allStringResults.add(result.getPersonalIdNumber());
allStringResults.add(result.getDocumentAdditionalNumber());
allStringResults.add(result.getDocumentOptionalAdditionalNumber());
allStringResults.add(result.getAdditionalPersonalIdNumber());
allStringResults.add(result.getIssuingAuthority());
DriverLicenseDetailedInfo driverLicenseInfo = result.getDriverLicenseDetailedInfo();
if (!driverLicenseInfo.isEmpty()) {
allStringResults.add(driverLicenseInfo.getRestrictions());
allStringResults.add(driverLicenseInfo.getConditions());
allStringResults.add(driverLicenseInfo.getEndorsements());
allStringResults.add(driverLicenseInfo.getVehicleClass());
for (VehicleClassInfo vehicleClassInfo : driverLicenseInfo.getVehicleClassesInfo()) {
allStringResults.add(vehicleClassInfo.getVehicleClass());
allStringResults.add(vehicleClassInfo.getLicenceType());
if (vehicleClassInfo.getEffectiveDate() != null) allStringResults.add(vehicleClassInfo.getEffectiveDate().getOriginalDateString());
if (vehicleClassInfo.getExpiryDate() != null) allStringResults.add(vehicleClassInfo.getExpiryDate().getOriginalDateString());
}
}
return allStringResults;
}

protected void drawLocationsOnBitmap(Canvas canvas, Paint paint, List<StringResult> stringResults, Side side) {
if (stringResults.size() == 0) return;
for (StringResult stringResult : stringResults) {
if (stringResult == null) continue;
if (!stringResult.value(AlphabetType.Latin).isEmpty() && stringResult.location(AlphabetType.Latin) != null && stringResult.side(AlphabetType.Latin) == side) {
paint.setColor(Color.GREEN);
canvas.drawRect(stringResult.location(AlphabetType.Latin).toRectF(), paint);
}
if (!stringResult.value(AlphabetType.Arabic).isEmpty() && stringResult.location(AlphabetType.Arabic) != null && stringResult.side(AlphabetType.Arabic) == side) {
paint.setColor(Color.RED);
canvas.drawRect(stringResult.location(AlphabetType.Arabic).toRectF(), paint);
}
if (!stringResult.value(AlphabetType.Cyrillic).isEmpty() && stringResult.location(AlphabetType.Cyrillic) != null && stringResult.side(AlphabetType.Cyrillic) == side) {
paint.setColor(Color.BLUE);
canvas.drawRect(stringResult.location(AlphabetType.Cyrillic).toRectF(), paint);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.microblink.blinkid.result.extract.blinkid.documentface;

import com.microblink.blinkid.entities.recognizers.blinkid.documentface.DocumentFaceRecognizer;
import com.microblink.blinkid.libutils.R;
import com.microblink.libutils.R;
import com.microblink.blinkid.result.extract.blinkid.BlinkIdExtractor;

public class DocumentFaceRecognitionResultExtractor extends BlinkIdExtractor<DocumentFaceRecognizer.Result, DocumentFaceRecognizer> {
Expand Down
Loading

0 comments on commit 0f5b39b

Please sign in to comment.