Comments (28)
Hi CroatianIDFrontSide is an example which shows how Templating API can be used to scan any document. You can modify it as you wish for your use case. The documentation for Templating API can help you understand what is being done inside the demo and demo is there to back the documentation with well-commented example.
from blinkid-android.
Ok, I will try it. Now we just close the issue, after that if got any problem, I will reopen or create another issue, is that ok?
from blinkid-android.
Sure.
from blinkid-android.
OK thanks alot.
from blinkid-android.
already defined DetectorSettings
Hi, I already follow the step but still not working. I
already set BlinkOCRRecognizerSettings
already set setDecodingInfos
I just want to scan one kind of the card so i skip then Classifier Class.
But now, when I want to scan the card, the screen do not have any respond, means never scan the card.
May I know what are the steps that missed cause it cannot scan the card?
How to get the result after the scan done?
thank you
from blinkid-android.
Does the demo app work for you? Can you provide a minimal Android Studio project which demonstrates the issue?
from blinkid-android.
Can I post the code for the template class I created to let you check?
from blinkid-android.
Please do so.
from blinkid-android.
public class CustomiseCard {
private static final String NAME = "name";
private static final String PASSPORT_NUMBER = "passportNumber";
private static final String DATE_OF_BIRTH = "dateOfBirth";
private static final String GENDER = "gender";
private static final String ADDRESS = "address";
private static final String CARD = "card";
private static final String TAG = "CustomiseCard";
private static void setupName(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
//String name = firstName ? NAME : NAME;
String name = NAME;
//int dewarpHeight = firstName ? 150:100;
/**
* For extracting first and last names, we will use regex parser with regular expression which
* attempts to extract as may uppercase words as possible from single line.
*/
RegexParserSettings nameParser = new RegexParserSettings("([A-Z]+ ?)+");
/**
* add parser to parser group
*/
settings.addParserToParserGroup(name, name, nameParser);
Rectangle locationName = new Rectangle(0.565f, 0.259f, 0.412f, 0.056f);
card.add(new DecodingInfo(locationName, 350, name ));
}
private static void setupDateOfBirth(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.389f, 0.176f, 0.056f),150, DATE_OF_BIRTH));
settings.addParserToParserGroup(DATE_OF_BIRTH,DATE_OF_BIRTH, new DateParserSettings());
}
private static void setupPassportNumber(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.315f, 0.412f, 0.056f), 350, PASSPORT_NUMBER));
RegexParserSettings documentNumberParser = new RegexParserSettings("\\d{9}");
settings.addParserToParserGroup(PASSPORT_NUMBER,PASSPORT_NUMBER,documentNumberParser );
}
private static void setupAddress(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.556f, 0.412f, 0.241f), 350, ADDRESS));
RegexParserSettings passportParser = new RegexParserSettings("([A-Z]+ ?)+");
settings.addParserToParserGroup(PASSPORT_NUMBER,PASSPORT_NUMBER,passportParser );
}
private static void setupGender(TemplatingRecognizerSettings settings, List<DecodingInfo> card) {
card.add(new DecodingInfo(new Rectangle(0.565f, 0.389f, 0.176f, 0.056f), 150, GENDER));
RegexParserSettings genderParser = new RegexParserSettings("[M]/[F]");
settings.addParser(GENDER, genderParser);
genderParser.getOcrEngineOptions().addCharToWhitelist('M', OcrFont.OCR_FONT_ANY)
.addCharToWhitelist('F', OcrFont.OCR_FONT_ANY);
genderParser.setMustEndWithWhitespace(true);
genderParser.setMustStartWithWhitespace(true);
settings.addParserToParserGroup(GENDER,GENDER, genderParser);
}
public static BlinkOCRRecognizerSettings buildICardRecogniserSettings(){
BlinkOCRRecognizerSettings settings = new BlinkOCRRecognizerSettings();
List<DecodingInfo> cardDecodingInfos = new ArrayList<>();
setupName(settings, cardDecodingInfos);
setupDateOfBirth(settings, cardDecodingInfos);
setupPassportNumber(settings, cardDecodingInfos);
setupAddress(settings, cardDecodingInfos);
setupGender(settings, cardDecodingInfos);
// setup card detector
DocumentSpecification idSpec = DocumentSpecification.createFromPreset(DocumentSpecificationPreset.DOCUMENT_SPECIFICATION_PRESET_ID1_CARD);
/*// set decoding info objects inherent to this document specification
idSpec.setDecodingInfos(TemplatingUtils.listToArray(classificationDecodingInfos));*/
// create card detector with single document specification
DocumentDetectorSettings dds = new DocumentDetectorSettings(new DocumentSpecification[]{idSpec});
// ensure this detector will be used when performing object detection
settings.setDetectorSettings(dds);
settings.setParserDecodingInfos(TemplatingUtils.listToArray( cardDecodingInfos),CARD );
settings.setAllowFlippedRecognition(true);
return settings;
}
}
from blinkid-android.
cannot upload the file because not supported by github even I compressed it become zip file. So i post it in the comment.
from blinkid-android.
From the quick look, the offending line would be
/*// set decoding info objects inherent to this document specification
idSpec.setDecodingInfos(TemplatingUtils.listToArray(classificationDecodingInfos));*/
This line is commented-out in your code, yet it contains decoding infos which are essential to determine the type of document, see the documentation. If you are only targeting single type of document, then decoding infos should be set in commented-out line. If you are targeting multiple types of documents, then with this line you set the decoding infos of locations which you use for classification of the document and then after classifier returns the classification result, you use decoding infos for that type of document set with setParserDecodingInfos
.
Basically, this means that in your code, you should this line
settings.setParserDecodingInfos(TemplatingUtils.listToArray( cardDecodingInfos),CARD );
replace with this line:
idSpec.setDecodingInfos(TemplatingUtils.listToArray(cardDecodingInfos));
Just make sure you set decoding infos to IDSpec before using it to create DocumentDetectorSettings
.
from blinkid-android.
Oh yea.. its work!! now got respond already. But now it cannot recognize the card. I will prompt out a dialog ask me to re-scan the card if it cannot be recognize.
Is it because the position of the information that I want to scan not match with the exact value of the information on the card?
from blinkid-android.
and for the position of the address, basically address have few lines in identity card, so it will auto scan through all the lines in the position?
from blinkid-android.
and one more question is can I straight away use the MyKadRecognitionResult after the scanning done? If can, I just change the name in the template?
for example:
private static final String NAME = "name";
change to
private static final String NAME = "ownerFullName";
ownerFullName is the name get from MyKadRecognitionResult class
from blinkid-android.
Is it because the position of the information that I want to scan not match with the exact value of the information on the card?
Yes, you need to define locations very precisely. Also, if card is mis-detected, then relative positions are also calculated incorrectly. You should take this into account.
and for the position of the address, basically address have few lines in identity card, so it will auto scan through all the lines in the position?
The OCR is performed on entire decoding location. For filtering-out patterns you truly need, you should define a good regular expression in regex parser or use specialised parsers, like date parser.
and one more question is can I straight away use the MyKadRecognitionResult after the scanning done?
MyKadRecognitionResult is result of MyKad recognizer. After obtaining the result of your card, you can reconfigure RecognizerView and set it to use only MyKad recognizer.
from blinkid-android.
Yes, you need to define locations very precisely.
the spacing between 2 information I want to get is only 1-2mm only, is it too small? the calculation I made I just take 3 decimal places which are follow the template.
MyKadRecognitionResult is result of MyKad recognizer. After obtaining the result of your card, you can reconfigure RecognizerView and set it to use only MyKad recognizer.
So I need to create my own RecognitionResult class? and inside the class add all the method for example getName(), getAddress(), etc...
from blinkid-android.
private static void setupDateOfBirth(TemplatingRecognizerSettings settings, List card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.389f, 0.176f, 0.056f),150, DATE_OF_BIRTH));
the parameter for 150 is for what value? range??
from blinkid-android.
So I need to create my own RecognitionResult class? and inside the class add all the method for example getName(), getAddress(), etc...
No, you will obtain results as written in documentation, using parser group/parser name strings you used when configuring parser groups (aka decoding infos) and parsers.
from blinkid-android.
the parameter for 150 is for what value?
This is the dewarp height of the location in pixels. Generally it should be set to number of expected text lines * 100, but feel free to experiment with different values until you get the best results.
from blinkid-android.
Cannot find parser group for location 'address'. Will not perform OCR and parsing of that location!
This message mean my calculation got problem?
from blinkid-android.
the coding below is the coding after on
public Customer onScanningDone(RecognitionResults results){
Customer customer = null;
BaseRecognitionResult[] dataArray = results.getRecognitionResults();
for(BaseRecognitionResult baseResult : dataArray) {
if(baseResult instanceof BlinkOCRRecognitionResult) {
BlinkOCRRecognitionResult result = (BlinkOCRRecognitionResult) baseResult;
// you can use getters of BlinkOCRRecognitionResult class to
// obtain scanned information
if(result.isValid() && !result.isEmpty()) {
// use the parser name provided to BlinkOCRRecognizerSettings to
// obtain parsed result provided by given parser
// obtain result of "myAmountParser" in default parsing group
Log.i(TAG, "card result is valid!!");
String name = result.getParsedResult("name");
String passport = result.getParsedResult("passportNumber");
String dob = result.getParsedResult("dateOfBirth");
String gender = result.getParsedResult("gender");
String address = result.getParsedResult("address");
Log.i(TAG, "Scan From ---> Name ))) " + name);
Log.i(TAG, "Scan From ---> passport ))) " + passport);
Log.i(TAG, "Scan From ---> dob ))) " + dob);
Log.i(TAG, "Scan From i---> gender ))) " + gender);
Log.i(TAG, "Scan From ---> address ))) " + address);
customer.setName(name);
customer.setGender(gender);
customer.setPassport(passport);
customer.setDob(dob);
customer.setAddress(address);
}
}
}
return customer;
}
for Date I use DateParserSettings
for other value I use RegexParserSettings
private static void setupDateOfBirth(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.389f, 0.176f, 0.056f),100, DATE_OF_BIRTH));
settings.addParserToParserGroup(DATE_OF_BIRTH,DATE_OF_BIRTH, new DateParserSettings());
Log.i(TAG, "Scan DOB");
}
private static void setupPassportNumber(TemplatingRecognizerSettings settings, List<DecodingInfo> card){
card.add(new DecodingInfo(new Rectangle(0.565f, 0.315f, 0.412f, 0.056f), 100, PASSPORT_NUMBER));
RegexParserSettings documentNumberParser = new RegexParserSettings("\\d{9}");
settings.addParser(PASSPORT_NUMBER,documentNumberParser );
Log.i(TAG, "Scan Passport");
}
the coding above are two function in my program. is that any problem?
because after the scanning done, my application will crash. and I cannot get the value after scanning done.
from blinkid-android.
is it need use addParserToParseGroup? because after I use it, the scanned image got detected each character already. but now the problem is it said that the result is not valid or empty, ask me scan again.
from blinkid-android.
Cannot find parser group for location 'address'. Will not perform OCR and parsing of that location!
This message mean my calculation got problem?
No, this means that you have created decoding info with name 'address', and have not set any parsers to parser group called 'address'.
from blinkid-android.
the coding above are two function in my program. is that any problem?
because after the scanning done, my application will crash. and I cannot get the value after scanning done.
It should not be. Which crash are you having?
from blinkid-android.
is it need use addParserToParseGroup? because after I use it, the scanned image got detected each character already. but now the problem is it said that the result is not valid or empty, ask me scan again.
Yes, each decoding info / location on detected document represents a new parser group and only parsers added to parser group of same name as decoding info name will run on OCR result obtained on that location.
For more information about parser groups, please read this. For more information how parser group fit into Templating API, please read this. For a detailed explanation of code examples, please check this whitepaper.
from blinkid-android.
yea.. I got it already. now just need to adjust the position for the information. THANKS A LOT!!
from blinkid-android.
If that solved your problem, please close this issue. If you run into a new problem, please open a new issue.
from blinkid-android.
ok thanks for your help.
from blinkid-android.
Related Issues (20)
- Camera view has no children?!? HOT 1
- How to change to front-facing camera using `RecognizerRunnerView`? HOT 3
- Blink id scan screen crashes for this. HOT 2
- USDL - Louisiana - Doesn't OCR/Decode the PDF barcode at the back of the card HOT 4
- Can't scan backside of ID card with BlinkIdSingleSideRecognizer() in custom option. HOT 3
- Error Migration from 5.20.0 to 6.0.0 - NoClassDefFoundError MicroblinkSDK HOT 3
- Reinstate x86 and x86_64 support. HOT 1
- Warning: This feature is not supported on camera without autofocus HOT 8
- How to set outer layer of the quad view with grey transparent overlay HOT 4
- The native library is loaded in the main thread, which generates an ANR HOT 7
- This entity is not allowed by currently active license! HOT 1
- Can not close error popup on 6.2.1 version HOT 3
- Background ANR at jdk.internal.misc.Unsafe.park HOT 10
- Invalid license buffer magic number. HOT 5
- doesn't read first/last name or doc number from some type of Chinese passport HOT 2
- DateResult and Date toString returns appended data instead of interleaved HOT 4
- Sample apps use an outdated version of BlinkID and don't compile with the current version (6.5.0) HOT 1
- com.microblink.blinkid.licence.exception.InvalidLicenceKeyException HOT 1
- Upgrading to Version 6.6.0 but the SDK is not working HOT 2
- Feature Request: Height, Eye Color, Hair Color, Weight Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blinkid-android.