在.NET中从图像中识别MICR E-13B字符

博客类别:OCR.NET

2022/02/17

VintaSoft Imaging .NET SDKVintaSoft OCR .NET Plug-in 插件允许使用 Tesseract OCR 引擎从图像中识别文本。Tesseract OCR 引擎拥有大量词典,支持 100 多种语言的文本识别。

互联网上有一些作者推荐了他们用于使用 Tesseract OCR 引擎识别 MICR E-13B 符号的免费词典。
我们测试了其中一些词典,并确保词典"e13b.traineddata"能够提供高质量的 MICR E-13B 符号识别,其识别质量可与专业的 MICR E-13B 符号识别器相媲美。
"e13b.traineddata"词典采用 BSD-3 许可,允许免费使用和分发。
我们创建了"e13b.traineddata"字典可从我们的网站下载,也可从其他互联网资源下载。

自 VintaSoft OCR .NET 插件版本 11.0.5.1 起,"e13b.traineddata"字典已添加到支持的字典列表(Vintasoft.Imaging.Ocr.OcrLanguage 枚举中的 MICR 项)中。

关于MICR符号的更多详细信息,您可以在维基百科上阅读:https://en.wikipedia.org/wiki/Magnetic_ink_character_recognition

以下是来自维基百科的图片,展示了 MICR E-13B 符号:



以下是 C# 代码,演示了如何使用 Tesseract OCR 引擎从图像中识别 MICR E-13B 符号:
/// <summary>
/// Recognizes MICR E-13B characters from image using Tesseract OCR engine.
/// </summary>
/// <param name="filename">The name of file, which stores images with MICR E-13B characters.</param>
public static void RecognizeMicrE13BCharactersUsingTesseractOCR(string filename)
{
    // create an image collection
    using (Vintasoft.Imaging.ImageCollection images = 
        new Vintasoft.Imaging.ImageCollection())
    {
        // add images from file to the image collection
        images.Add(filename);

        System.Console.WriteLine("Create Tesseract OCR engine...");
        // create the Tesseract OCR engine
        using (Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr tesseractOcr = 
            new Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr())
        {
            System.Console.WriteLine("Initialize OCR engine...");
            // init the Tesseract OCR engine for recognition of MICR E-13B characters
            tesseractOcr.Init(new Vintasoft.Imaging.Ocr.OcrEngineSettings(Vintasoft.Imaging.Ocr.OcrLanguage.MICR));

            // for each image in image collection
            foreach (Vintasoft.Imaging.VintasoftImage image in images)
            {
                System.Console.WriteLine("Recognize the image...");
                
                // recognize text in image
                Vintasoft.Imaging.Ocr.Results.OcrPage ocrResult = tesseractOcr.Recognize(image);

                // output the recognized text

                System.Console.WriteLine("Page Text:");
                System.Console.WriteLine(ocrResult.GetText());
                System.Console.WriteLine();
            }

            // shutdown the Tesseract OCR engine
            tesseractOcr.Shutdown();
        }

        // free images
        images.ClearAndDisposeItems();
    }
}