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 : Friday, January 11, 2019 12:07:16 PM(UTC)
Pawel L.

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


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);

   IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
   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:
p1.jpg
Output:
p2.png
Pawel Lyko
Developer Support Engineer
LEAD Technologies, Inc.

 

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-2024, Yet Another Forum.NET
This page was generated in 0.060 seconds.