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 : Monday, April 17, 2017 9:52:24 AM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 218

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

Attached is a VS2017 C# project that uses the Leadtools Image processing and OCR SDK's in order to automate the process of checks. The Image processing command that is doing most of the work is the MICRCodeDetectionCommand:
https://www.leadtools.co...odedetectioncommand.html

Here is the relevant method for achieving this:

Code:
private string DetectandRecognizeMICR(string fileName)
      {
         try
         {
            string micr = "";
            //Initialize the codecs class and load the image
            using (RasterCodecs codecs = new RasterCodecs())
            {
               using (RasterImage img = codecs.Load(fileName))
               {
                  //prepare the MICR detector command and run it
                  MICRCodeDetectionCommand micrDetector = new MICRCodeDetectionCommand();
                  micrDetector.SearchingZone = new LeadRect(0, 0, img.Width, img.Height);
                  micrDetector.Run(img);

                  //See if there is a MICR detected - if not return
                  if (micrDetector.MICRZone == LeadRect.Empty)
                     return "No MICR detected in this file.";

                  //if there is a MICR zone detected startup OCR
                  using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
                  {
                     ocrEngine.Startup(null, null, null, null);

                     //create the OCR Page
                     IOcrPage ocrPage = ocrEngine.CreatePage(img, OcrImageSharingMode.None);

                     //Create the OCR zone for the MICR and add to the Ocr Page and recognize
                     OcrZone micrZone = new OcrZone();
                     micrZone.Bounds = LogicalRectangle.FromRectangle(micrDetector.MICRZone);
                     micrZone.ZoneType = OcrZoneType.Micr;
                     ocrPage.Zones.Add(micrZone);
                     ocrPage.Recognize(null);

                     //return the MICR text
                     micr = ocrPage.GetText(-1);
                  }
               }
            }
            return micr;
         }
         catch (Exception ex)
         {
            return ex.Message;
         }
      }


Please note that if you wish to make this into an automated process, you should not dispose of the OCREngine and should only start it up when the application/ thread is started and then shut it down/dispose of it once the application/thread is stopped.

File Attachment(s):
MICR Detector Demo.zip (4kb) downloaded 370 time(s).


Update:
This project contains configurations for running against LEADTOOLS 19 and LEADTOOLS 20.
File Attachment(s):
MICR Detector Demo_v19_v20.zip (6kb) downloaded 185 time(s).

Edited by moderator Friday, June 22, 2018 10:20:11 AM(UTC)  | Reason: Not specified

Hadi Chami
Developer Support Manager
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.

#2 Posted : Tuesday, April 10, 2018 8:06:32 AM(UTC)

Hussam  
Hussam

Groups: Registered, Tech Support
Posts: 14


Attached is the same project but modified to run using version 20 of the LEADTOOLS toolkit with the modified assembly names and the LEAD OCR engine (Which was renamed from the Advantage engine).

File Attachment(s):
V20_MICRDetectorDemo.zip (5kb) downloaded 248 time(s).
Hussam Barouqa
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
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.090 seconds.