How to check MICR code for validity after the OCR step?

1.1k views Asked by At

AFTER a check has been scanned and the MICR code has been generated from that scan, what can be check about that code other than counting the number of digits, to gain confidence that it is valid or at least internally consistent?

I already know that the MICR code is a 9-digit routing number that the checking-account belongs to. But else can be check about it? Does it follow any pattern that could give a hint if any digit has been read incorrectly?

E.g. this code simply checks for 9 digits (I'm using C# but it doesn't matter what language the answers employ):

'''C# Regex regex = new Regex(@"^[0-9]{9}$");

I would expect the answer to be true or false. I can then derive the appropriate error-description.

1

There are 1 answers

0
hcham1 On

You would need to refer to the MICR specification in order to properly validate that the MICR read is valid. See the PDF here: MICR Basics Handbook

Here are a couple screenshots that should help you parse out the various sections of the MICR:

micr example check screenshot

micr field explanations

Otherwise, you could check out a commercial library that handles this for you and keeps up to date with the specification. The company I work for has one such library that you can check out here: https://www.leadtools.com/sdk/ocr/micr Specifically, you can use the high-level BankCheckReader class which is able to find the micr line on any page in either or both E13b and Cmc7 micr font type.

Here is some sample code in C# but this class is also available in java and other languages:

BankCheckReader checkReader = new BankCheckReader(); 
IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD); 
ocrEngine.Startup(null, null, null, null); 
checkReader.OcrEngine = ocrEngine; 
checkReader.MicrFontType = BankCheckMicrFontType.E13b; 
checkReader.ProcessImage(image);