Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, July 25, 2017 2:41:03 PM(UTC)
Nick Villalobos

Groups: Registered, Manager, Tech Support, Administrators
Posts: 79

Was thanked: 2 time(s) in 2 post(s)

Below you will find a Java code snippet of how you can read and extract data from a passport.
Remember, in order to retrieve the most accurate results, you will want to have a very crisp and clear image so the engine will not have trouble during the process.

Code:

// Set your license
RasterSupport.setLicense(licenseFile, developerKey);

try{
    if(RasterSupport.getKernelExpired()) {
    System.out.println("License NOT Set Successfully");
    }
    else {
    System.out.println("License Set Successfully");
    }

RasterCodecs rasterCodecs = new RasterCodecs();
MRTDReader mrtdReader = new MRTDReader();
String stream = "PASSPORT_IMAGE.jpg";

RasterImage rasterImage = rasterCodecs.load(stream);

OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.ADVANTAGE);
ocrEngine.startup(rasterCodecs, null, null, null);

		
mrtdReader.setOcrEngine(ocrEngine);
mrtdReader.processImage(rasterImage);		
mrtdReader.setImproveResults(true);
HashMap<MRTDField, MRTDDataElement> ar = new HashMap<>();
ar = mrtdReader.getResults();

String[] string = mrtdReader.getLines();
		
for (String string2 : string) {
	System.out.println(string2);
}
				
for (Map.Entry<MRTDField, MRTDDataElement> map : ar.entrySet()) {
MRTDField key = map.getKey();
System.out.println(key);
MRTDDataElement value = map.getValue();
System.out.println(value.getReadableValue());
}
		
ocrEngine.shutdown();
}
catch(Exception e)
{
	e.printStackTrace();
	throw new Exception(e);
}


Passport being recognized:

Passport Sample

Output:

output
Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2017, Yet Another Forum.NET
This page was generated in 0.125 seconds.