Skip to content

Commit

Permalink
Merge pull request #49 from BlinkID/release/v3.10.0
Browse files Browse the repository at this point in the history
Release/v3.10.0
  • Loading branch information
DoDoENT authored Jul 28, 2017
2 parents 6774677 + d339843 commit d23cbfe
Show file tree
Hide file tree
Showing 87 changed files with 5,750 additions and 572 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.microblink.recognizers.blinkid.austria.back.AustrianIDBackSideRecognizerSettings;
import com.microblink.recognizers.blinkid.austria.combined.AustrianIDCombinedRecognizerSettings;
import com.microblink.recognizers.blinkid.austria.front.AustrianIDFrontSideRecognizerSettings;
import com.microblink.recognizers.blinkid.austria.passport.AustrianPassportRecognizerSettings;
import com.microblink.recognizers.blinkid.croatia.back.CroatianIDBackSideRecognizerSettings;
import com.microblink.recognizers.blinkid.croatia.combined.CroatianIDCombinedRecognizerSettings;
import com.microblink.recognizers.blinkid.croatia.front.CroatianIDFrontSideRecognizerSettings;
Expand Down Expand Up @@ -62,6 +63,7 @@
import com.microblink.recognizers.blinkid.slovenia.back.SlovenianIDBackSideRecognizerSettings;
import com.microblink.recognizers.blinkid.slovenia.combined.SlovenianIDCombinedRecognizerSettings;
import com.microblink.recognizers.blinkid.slovenia.front.SlovenianIDFrontSideRecognizerSettings;
import com.microblink.recognizers.blinkid.switzerland.passport.SwissPassportRecognizerSettings;
import com.microblink.recognizers.blinkid.usdl.combined.USDLCombinedRecognizerSettings;
import com.microblink.recognizers.blinkocr.parser.licenseplates.LicensePlatesParserSettings;
import com.microblink.recognizers.blinkocr.parser.vin.VinParserSettings;
Expand Down Expand Up @@ -236,6 +238,7 @@ private Intent buildIntent(RecognizerSettings[] settArray, Class<?> target, Inte
/**
* This method will build scan intent for {@link com.microblink.activity.VerificationFlowActivity}
* with given combined recognizer settings.
*
* @param combinedRecognizerSettings settings for the combined recognizer that will be used.
*/
private Intent buildCombinedIntent(CombinedRecognizerSettings combinedRecognizerSettings) {
Expand All @@ -248,12 +251,13 @@ private Intent buildCombinedIntent(CombinedRecognizerSettings combinedRecognizer

/**
* Builds intent for segment scan.
*
* @param configArray Array of scan configurations. Each scan configuration
* contains 4 elements: resource ID for title displayed
* in BlinkOCRActivity activity, resource ID for text
* displayed in activity, name of the scan element (used
* for obtaining results) and parser setting defining
* how the data will be extracted.
* contains 4 elements: resource ID for title displayed
* in BlinkOCRActivity activity, resource ID for text
* displayed in activity, name of the scan element (used
* for obtaining results) and parser setting defining
* how the data will be extracted.
* @return Built intent for segment scan.
*/
private Intent buildSegmentScanIntent(ScanConfiguration[] configArray) {
Expand Down Expand Up @@ -283,13 +287,14 @@ private void buildElements() {
elements.add(buildMrtdElement());
elements.add(buildAustrianIDElement());
elements.add(buildAustrianIDCombinedElement());
elements.add(buildAustrianPassportElement());
elements.add(buildCroatianIDElement());
elements.add(buildCroatianIDCombinedElement());
elements.add(buildCzechIDElement());
elements.add(buildCzechIDCombinedElement());
elements.add(buildGermanIDElement());
elements.add(buildGermanPassportElement());
elements.add( buildGermanIDCombinedElement() );
elements.add(buildGermanIDCombinedElement());
elements.add(buildMyKadElement());
elements.add(buildIKadElement());
elements.add(bildRomanianElement());
Expand All @@ -301,6 +306,7 @@ private void buildElements() {
elements.add(buildSlovakIDCombinedElement());
elements.add(buildSlovenianIDElement());
elements.add(buildSlovenianIDCombinedElement());
elements.add(buildSwissPassportElement());

// DL list entries
elements.add(buildAustrianDLElement());
Expand Down Expand Up @@ -345,6 +351,11 @@ private ListElement buildAustrianIDElement() {
return new ListElement("Austrian ID", buildIntent(new RecognizerSettings[]{ausFront, ausBack}, ScanCard.class, null));
}

private ListElement buildAustrianPassportElement() {
AustrianPassportRecognizerSettings ausPass = new AustrianPassportRecognizerSettings();
return new ListElement("Austrian Passport", buildIntent(new RecognizerSettings[]{ausPass}, ScanCard.class, null));
}

private ListElement buildCroatianIDElement() {
CroatianIDFrontSideRecognizerSettings croFront = new CroatianIDFrontSideRecognizerSettings();
CroatianIDBackSideRecognizerSettings croBack = new CroatianIDBackSideRecognizerSettings();
Expand All @@ -364,7 +375,7 @@ private ListElement buildGermanIDElement() {
GermanIDBackSideRecognizerSettings deBack = new GermanIDBackSideRecognizerSettings();
GermanOldIDRecognizerSettings deOld = new GermanOldIDRecognizerSettings();

return new ListElement( "German ID", buildIntent( new RecognizerSettings[] { deFront, deBack, deOld }, ScanCard.class, null ));
return new ListElement("German ID", buildIntent(new RecognizerSettings[]{deFront, deBack, deOld}, ScanCard.class, null));
}

private ListElement buildGermanPassportElement() {
Expand Down Expand Up @@ -401,6 +412,12 @@ private ListElement buildSlovenianIDElement() {
return new ListElement("Slovenian ID", buildIntent(new RecognizerSettings[]{sloFront, sloBack}, ScanCard.class, null));
}

private ListElement buildSwissPassportElement() {
SwissPassportRecognizerSettings swissPass = new SwissPassportRecognizerSettings();

return new ListElement("Swiss Passport", buildIntent(new RecognizerSettings[]{swissPass}, ScanCard.class, null));
}

private ListElement buildUKDLElement() {
// prepare settings for United Kingdom Driver's Licence recognizer
EUDLRecognizerSettings ukdl = new EUDLRecognizerSettings(EUDLCountry.EUDL_COUNTRY_UK);
Expand Down Expand Up @@ -453,10 +470,10 @@ private ListElement buildIKadElement() {
return new ListElement("Malaysian iKad document", buildIntent(new RecognizerSettings[]{iKad}, ScanCard.class, null));
}

private ListElement bildRomanianElement () {
private ListElement bildRomanianElement() {
RomanianIDFrontSideRecognizerSettings romanianSettings = new RomanianIDFrontSideRecognizerSettings();

return new ListElement("Romanian ID", buildIntent( new RecognizerSettings[] { romanianSettings }, ScanCard.class, null ));
return new ListElement("Romanian ID", buildIntent(new RecognizerSettings[]{romanianSettings}, ScanCard.class, null));
}

private ListElement buildCroatianIDCombinedElement() {
Expand Down Expand Up @@ -516,7 +533,7 @@ private ListElement buildUsdlCombinedElement() {
private ListElement buildGermanIDCombinedElement() {
GermanIDCombinedRecognizerSettings deCombined = new GermanIDCombinedRecognizerSettings();

return new ListElement( "German ID combined", buildCombinedIntent( deCombined ) );
return new ListElement("German ID combined", buildCombinedIntent(deCombined));
}

private ListElement buildPDF417Element() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.microblink.recognizers.blinkid.mrtd.MRTDDocumentClassifier;
import com.microblink.recognizers.blinkid.mrtd.MRTDRecognitionResult;
import com.microblink.recognizers.blinkid.mrtd.MRTDRecognizerSettings;
import com.microblink.recognizers.blinkocr.engine.BlinkOCREngineOptions;
import com.microblink.recognizers.blinkocr.parser.generic.DateParserSettings;
import com.microblink.recognizers.blinkocr.parser.regex.RegexParserSettings;
import com.microblink.recognizers.templating.TemplatingRecognizerSettings;
Expand Down Expand Up @@ -99,8 +100,8 @@ private static void setupAddress(TemplatingRecognizerSettings settings, List<Dec
* To ensure optimal OCR results, we will allow only uppercase letters and digits in OCR. Thus, OCR
* will not return lowercase letters, reducing the possibility of misreads.
*/
CroatianIDFrontSide.addAllCroatianUppercaseCharsToWhitelist(addressParser.getOcrEngineOptions());
addressParser.getOcrEngineOptions().addAllDigitsToWhitelist(OcrFont.OCR_FONT_ANY);
CroatianIDFrontSide.addAllCroatianUppercaseCharsToWhitelist((BlinkOCREngineOptions)addressParser.getOcrEngineOptions());
((BlinkOCREngineOptions)addressParser.getOcrEngineOptions()).addAllDigitsToWhitelist(OcrFont.OCR_FONT_ANY);
addressParser.getOcrEngineOptions().setColorDropoutEnabled(false);
addressParser.getOcrEngineOptions().setMinimumCharHeight(35);

Expand Down Expand Up @@ -132,7 +133,7 @@ private static void setupAddress(TemplatingRecognizerSettings settings, List<Dec
*/
private static void setupIssuedBy(TemplatingRecognizerSettings settings, List<DecodingInfo> oldId, List<DecodingInfo> newId) {
RegexParserSettings issuedByParser = new RegexParserSettings("P[PU] ([A-ZŠĐŽČĆ]+ ?)+");
CroatianIDFrontSide.addAllCroatianUppercaseCharsToWhitelist(issuedByParser.getOcrEngineOptions());
CroatianIDFrontSide.addAllCroatianUppercaseCharsToWhitelist((BlinkOCREngineOptions)issuedByParser.getOcrEngineOptions());
issuedByParser.getOcrEngineOptions().setColorDropoutEnabled(false);
issuedByParser.getOcrEngineOptions().setMinimumCharHeight(20);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static void setupName(TemplatingRecognizerSettings settings, List<Decodi
/**
* tweak OCR engine options - allow only recognition of uppercase letters used in Croatia
*/
addAllCroatianUppercaseCharsToWhitelist(nameParser.getOcrEngineOptions());
addAllCroatianUppercaseCharsToWhitelist((BlinkOCREngineOptions)nameParser.getOcrEngineOptions());

/**
* add parser to parser group
Expand Down Expand Up @@ -224,7 +224,7 @@ private static void setupSexCitizenshipAndDateOfBirth(TemplatingRecognizerSettin
* final whitelist for OCR will be obtained by merging all whitelists of all
* parsers in same parser group.
*/
sexParser.getOcrEngineOptions().addCharToWhitelist('M', OcrFont.OCR_FONT_ANY)
((BlinkOCREngineOptions)sexParser.getOcrEngineOptions()).addCharToWhitelist('M', OcrFont.OCR_FONT_ANY)
.addCharToWhitelist('F', OcrFont.OCR_FONT_ANY)
.addCharToWhitelist('Ž', OcrFont.OCR_FONT_ANY)
.addCharToWhitelist('/', OcrFont.OCR_FONT_ANY);
Expand All @@ -241,7 +241,7 @@ private static void setupSexCitizenshipAndDateOfBirth(TemplatingRecognizerSettin
* which will be added to same parser group
*/
RegexParserSettings citizenshipParser = new RegexParserSettings("[A-Z]{3}");
addAllCroatianUppercaseCharsToWhitelist(citizenshipParser.getOcrEngineOptions());
addAllCroatianUppercaseCharsToWhitelist((BlinkOCREngineOptions)citizenshipParser.getOcrEngineOptions());
citizenshipParser.setMustEndWithWhitespace(true);
citizenshipParser.setMustStartWithWhitespace(true);

Expand Down Expand Up @@ -288,7 +288,7 @@ private static void setupDocumentNumber(TemplatingRecognizerSettings settings, L
* regex parser which only allows digits in OCR engine settings.
*/
RegexParserSettings documentNumberParser = new RegexParserSettings("\\d{9}");
documentNumberParser.getOcrEngineOptions().addAllDigitsToWhitelist(OcrFont.OCR_FONT_ANY);
((BlinkOCREngineOptions)documentNumberParser.getOcrEngineOptions()).addAllDigitsToWhitelist(OcrFont.OCR_FONT_ANY);
documentNumberParser.getOcrEngineOptions().setMinimumCharHeight(35);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
public class Config {
// obtain your licence key at http://microblink.com/login or
// contact us at http://help.microblink.com
public static final String LICENSE_KEY = "223NEUYL-776FCZVB-DSVRVKKG-2ET7OWCT-KW2DLAFS-PSI7SSM7-JDHZRECF-LFJSEZWQ";
public static final String LICENSE_KEY = "QMNQCCN5-2ERQKUYV-4LIKXHAH-FVQJG6VR-FZ57UXRG-3LLCZ6S6-E3NNNDBS-55RNBZ25";
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.microblink.libresult.extract.austria.AustrianIDBackSideRecognitionResultExtractor;
import com.microblink.libresult.extract.austria.AustrianIDCombinedRecognitionResultExtractor;
import com.microblink.libresult.extract.austria.AustrianIDFrontSideRecognitionResultExtractor;
import com.microblink.libresult.extract.austria.AustrianPassportRecognitionResultExtractor;
import com.microblink.libresult.extract.barcode.BarcodeRecognitionResultExtractor;
import com.microblink.libresult.extract.barcode.Pdf417RecognitionResultExtractor;
import com.microblink.libresult.extract.blinkInput.BlinkOcrRecognitionResultExtractor;
Expand Down Expand Up @@ -51,6 +52,7 @@
import com.microblink.libresult.extract.slovenia.SlovenianIDBackRecognitionResultExtractor;
import com.microblink.libresult.extract.slovenia.SlovenianIDCombinedRecognitionResultExtractor;
import com.microblink.libresult.extract.slovenia.SlovenianIDFrontRecognitionResultExtractor;
import com.microblink.libresult.extract.switzerland.SwissPassportRecognitionResultExtractor;
import com.microblink.locale.LanguageUtils;
import com.microblink.recognizers.BaseRecognitionResult;
import com.microblink.recognizers.blinkbarcode.barcode.BarcodeScanResult;
Expand All @@ -59,6 +61,7 @@
import com.microblink.recognizers.blinkid.austria.back.AustrianIDBackSideRecognitionResult;
import com.microblink.recognizers.blinkid.austria.combined.AustrianIDCombinedRecognitionResult;
import com.microblink.recognizers.blinkid.austria.front.AustrianIDFrontSideRecognitionResult;
import com.microblink.recognizers.blinkid.austria.passport.AustrianPassportRecognitionResult;
import com.microblink.recognizers.blinkid.croatia.back.CroatianIDBackSideRecognitionResult;
import com.microblink.recognizers.blinkid.croatia.combined.CroatianIDCombinedRecognitionResult;
import com.microblink.recognizers.blinkid.croatia.front.CroatianIDFrontSideRecognitionResult;
Expand Down Expand Up @@ -87,6 +90,7 @@
import com.microblink.recognizers.blinkid.slovenia.back.SlovenianIDBackSideRecognitionResult;
import com.microblink.recognizers.blinkid.slovenia.combined.SlovenianIDCombinedRecognitionResult;
import com.microblink.recognizers.blinkid.slovenia.front.SlovenianIDFrontSideRecognitionResult;
import com.microblink.recognizers.blinkid.switzerland.passport.SwissPassportRecognitionResult;
import com.microblink.recognizers.blinkocr.BlinkOCRRecognitionResult;

import java.util.List;
Expand Down Expand Up @@ -146,6 +150,8 @@ public void onCreate(Bundle savedInstanceState) {
mResultExtractor = new AustrianIDFrontSideRecognitionResultExtractor(getActivity());
} else if (mData instanceof AustrianIDCombinedRecognitionResult) {
mResultExtractor = new AustrianIDCombinedRecognitionResultExtractor(getActivity());
} else if (mData instanceof AustrianPassportRecognitionResult) {
mResultExtractor = new AustrianPassportRecognitionResultExtractor(getActivity());
} else if (mData instanceof CroatianIDBackSideRecognitionResult) {
mResultExtractor = new CroatianIDBackSideRecognitionResultExtractor(getActivity());
} else if (mData instanceof CroatianIDFrontSideRecognitionResult) {
Expand Down Expand Up @@ -188,6 +194,8 @@ public void onCreate(Bundle savedInstanceState) {
mResultExtractor = new SlovenianIDFrontRecognitionResultExtractor(getActivity());
} else if (mData instanceof SlovenianIDCombinedRecognitionResult) {
mResultExtractor = new SlovenianIDCombinedRecognitionResultExtractor(getActivity());
} else if (mData instanceof SwissPassportRecognitionResult) {
mResultExtractor = new SwissPassportRecognitionResultExtractor(getActivity());
} else if (mData instanceof IKadRecognitionResult) {
mResultExtractor = new IKadRecognitionResultExtractor(getActivity());
} else if(mData instanceof MRTDRecognitionResult) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.microblink.libresult.extract.austria;

import android.content.Context;

import com.microblink.libresult.R;
import com.microblink.libresult.extract.RecognitionResultEntry;
import com.microblink.libresult.extract.mrtd.MRTDRecognitionResultExtractor;
import com.microblink.recognizers.BaseRecognitionResult;
import com.microblink.recognizers.blinkid.austria.passport.AustrianPassportRecognitionResult;
import com.microblink.results.date.Date;

import java.util.List;


/**
* Result extractor for Austrian passport
*/
public class AustrianPassportRecognitionResultExtractor extends MRTDRecognitionResultExtractor{

public AustrianPassportRecognitionResultExtractor(Context context) {
super(context);
}

@Override
public List<RecognitionResultEntry> extractData(BaseRecognitionResult result) {
if (result == null) {
return mExtractedData;
}

if (result instanceof AustrianPassportRecognitionResult) {
AustrianPassportRecognitionResult autPassResult = (AustrianPassportRecognitionResult) result;

String name = autPassResult.getName();
if (name != null && !name.isEmpty()) {
mExtractedData.add(mBuilder.build(
R.string.PPFirstName,
name
));
}

String surname = autPassResult.getSurname();
if (surname != null && !surname.isEmpty()) {
mExtractedData.add(mBuilder.build(
R.string.PPLastName,
surname
));
}

String placeOfBirth = autPassResult.getPlaceOfBirth();
if (placeOfBirth != null) {
mExtractedData.add(mBuilder.build(
R.string.PPPlaceOfBirth,
placeOfBirth
));
}

String sex = autPassResult.getNonMRZSex();
if (sex != null) {
mExtractedData.add(mBuilder.build(
R.string.PPSex,
sex
));
}

String nat = autPassResult.getNonMRZNationality();
if (nat != null && !nat.isEmpty()) {
mExtractedData.add(mBuilder.build(
R.string.PPNationality,
nat
));
}

String authority = autPassResult.getAuthority();
if (authority != null && !authority.isEmpty()) {
mExtractedData.add(mBuilder.build(
R.string.PPAuthority,
authority
));
}

Date dateOfBirth = autPassResult.getNonMRZDateOfBirth();
if (dateOfBirth != null) {
mExtractedData.add(mBuilder.build(
R.string.PPDateOfBirth,
dateOfBirth
));
}

Date dateOfIssue = autPassResult.getDateOfIssue();
if (dateOfIssue != null) {
mExtractedData.add(mBuilder.build(
R.string.PPIssueDate,
dateOfIssue
));
}

Date dateOfExpiry = autPassResult.getNonMRZDateOfExpiry();
if (dateOfExpiry != null) {
mExtractedData.add(mBuilder.build(
R.string.PPDateOfExpiry,
dateOfExpiry
));
}

String height = autPassResult.getHeight();
if (height != null) {
mExtractedData.add(mBuilder.build(
R.string.PPHeight,
height
));
}

String passportNumber = autPassResult.getPassportNumber();
if (passportNumber != null) {
mExtractedData.add(mBuilder.build(
R.string.PPPassportNumber,
passportNumber
));
}

super.extractMRZData(autPassResult);
}

return mExtractedData;
}
}
Loading

0 comments on commit d23cbfe

Please sign in to comment.