In This Topic ▼

MICR Magnetic Ink Character Recognition

Magnetic Ink Character Recognition(MICR) is one of the supported fill methods in both LEADTOOLS LEAD and Omnipage OCR engines. 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#
VB
// 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, false); 
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); 
 
// *** Step 2: Load the TIF image that contains the MICR document to be recognized 
string imageFile = @"C:\Users\Public\Documents\LEADTOOLS 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(); 
' 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  
Dim ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, False) 
ocrEngine.Startup(Nothing, Nothing, Nothing, "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime") 
 
' *** Step 2 Load the TIF image that contains the MICR document To be recognized 
Dim imageFile As String = "C:\Users\Public\Documents\LEADTOOLS Images\MICR_SAMPLE.tif" 
Dim image As RasterImage = ocrEngine.RasterCodecsInstance.Load(imageFile, 1) 
 
' *** Step 3 Create an OCR page from this image 
Dim ocrPage As IOcrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose) 
 
Dim micrLocation As LeadRect 
 
' *** 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 
Dim micrCodeDetection As New Leadtools.ImageProcessing.Core.MICRCodeDetectionCommand() 
micrCodeDetection.Run(image) 
micrLocation = micrCodeDetection.MICRZone 
 
Dim zoneIndex As Integer = 0 
Dim zone As New OcrZone() 
zone.Bounds = micrLocation 
zone.ZoneType = OcrZoneType.Micr 
ocrPage.Zones.Add(zone) 
 
' *** Step 5 Recognize 
ocrPage.Recognize(Nothing) 
 
' *** Step 6 Get the results As text 
Dim text As String = 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 
Dim micrData As OcrMicrData = 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

An Overview of OCR Recognition Modules

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 20.0.2019.9.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Imaging, Medical, and Document