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:57:24 AM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

Was thanked: 5 time(s) in 5 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 83 time(s).
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.

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.131 seconds.