In This Topic ▼

MICR Magnetic Ink Character Recognition

Magnetic Ink Character Recognition(MICR) is one of the supported fill methods in LEADTOOLS LEAD engine. MICR is used to describe the special numbers and symbols you typically see at the bottom of checks, along with the technology and processes to produce and analyze these characters.

You can recognize MICR fonts using any of the LEADTOOLS OCR engines mentioned above by setting the OcrZone.FillMethod to NativeOcrZoneFillMethod.Micr and then recognizing your page.

The following example shows how to recognize MICR zones:

Example

C#
// Assuming you already added the correct references and the 
// following using statements at the beginning of your class: 
// using Leadtools; 
// using Leadtools.Ocr; 
 
// *** Step 1: Start an OCR engine 
 
// We will use the LEADTOOLS OCR Module - LEAD Engine  
IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD); 
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"); 
 
// *** Step 2: Load the TIF image that contains the MICR document to be recognized 
string imageFile = @"C:\LEADTOOLS23\Resources\Images\MICR_SAMPLE.tif"; 
RasterImage image = ocrEngine.RasterCodecsInstance.Load(imageFile, 1); 
 
// *** Step 3: Create an OCR page from this image 
IOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose); 
 
LeadRect micrLocation; 
 
// *** Step 4: Add an OCR MICR zone around the MICR font area 
//   Either set the location manually if known. For example, this is for MICR_SAMPLE.tif: 
// micrLocation = new LeadRect(38, 678, 1655, 87); 
//   Or use the MICRCodeDetectionCommand to automaitcally detect the location 
Leadtools.ImageProcessing.Core.MICRCodeDetectionCommand micrCodeDetection = new Leadtools.ImageProcessing.Core.MICRCodeDetectionCommand(); 
micrCodeDetection.Run(image); 
micrLocation = micrCodeDetection.MICRZone; 
 
int zoneIndex = 0; 
OcrZone zone = new OcrZone(); 
zone.Bounds = micrLocation; 
zone.ZoneType = OcrZoneType.Micr; 
ocrPage.Zones.Add(zone); 
 
// *** Step 5: Recognize 
ocrPage.Recognize(null); 
 
// *** Step 6: Get the results as text 
string text = ocrPage.GetText(zoneIndex); 
Console.WriteLine("The MICR characters recognized on this check are:"); 
Console.WriteLine(text); 
 
// Optionally, you can use the OcrMicrData helper class to parse the MICR data: 
OcrMicrData micrData = ocrPage.GetRecognizedCharacters()[0].ExtractMicrData(); 
Console.WriteLine("Parsed MICR data:"); 
Console.WriteLine("Auxiliary:" + micrData.Auxiliary); 
Console.WriteLine("EPC:" + micrData.Epc); 
Console.WriteLine("Routing:" + micrData.Routing); 
Console.WriteLine("Account:" + micrData.Account); 
Console.WriteLine("CheckNumber:" + micrData.CheckNumber); 
Console.WriteLine("Amount:" + micrData.Amount); 
 
// Alternatively you can create an IOcrDocument and add the page to it to save it to 
// any of the supported formats instead 
 
// *** Step 7: Clean up 
ocrPage.Dispose(); 
ocrEngine.Dispose(); 

References

Leadtools.Ocr Introduction

Leadtools.Ocr Getting Started (Guide to Example Programs)

Programming with LEADTOOLS .NET OCR

Creating an OCR Engine Instance

Starting and Shutting Down the OCR Engine

OCR Spell Language Dictionaries

Working with OCR Languages

Working with OCR Pages

Working with OCR Zones

Recognizing OCR Pages

OCR Confidence Reporting

OCR Languages and Spell Checking

OCR Engine-Specific Settings

OCR Tutorial - Working with Pages

OCR Tutorial - Recognizing Pages

OCR Tutorial - Adding and Painting Zones

OCR Tutorial - Working with Recognition Results

OCR Tutorial - Scanning to Searchable PDF

Help Version 23.0.2024.3.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Imaging, Medical, and Document

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.