LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Automatically detect and recognize checks using MICR Detection and OCR
#1
Posted
:
Monday, April 17, 2017 9:52:24 AM(UTC)
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.htmlHere 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.
Update:
This project contains configurations for running against LEADTOOLS 19 and LEADTOOLS 20.
Edited by moderator Friday, June 22, 2018 10:20:11 AM(UTC)
| Reason: Not specified
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
#2
Posted
:
Tuesday, April 10, 2018 8:06:32 AM(UTC)
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).
Hussam Barouqa
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Automatically detect and recognize checks using MICR Detection and OCR
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.