.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」辞書は 弊社 Web サイト からダウンロードできます。また、この辞書は他のインターネット リソースからもダウンロードできます。

VintaSoft OCR .NET Plug-in バージョン 11.0.5.1 以降、サポートされる辞書のリスト (Vintasoft.Imaging.Ocr.OcrLanguage 列挙の MICR 項目) に「e13b.traineddata」辞書が追加されました。

MICR シンボルの詳細については、Wikipedia: https://en.wikipedia.org/wiki/Magnetic_ink_character_recognition をご覧ください。

こちらはWikipediaから引用したMICR E-13Bシンボルの画像です:



こちらはTesseract OCRエンジンを使用して画像からMICR E-13Bシンボルを認識する方法を示したC#コードです:
/// <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();
    }
}