VintaSoft Imaging .NET SDK v8.8 for .NET Framework
In This Topic
    OCR: Prepare OCR engine for text recognition
    In This Topic

    Create an instance of TesseractOcr class

    For text recognition using Tesseract OCR it is necessary the following files:

    IMPORTANT: Microsoft Visual C++ 2017 Redistributable Package (32-bit version) must be installed on computer for correct work of Tesseract4.Vintasoft.x86.dll. Microsoft Visual C++ 2017 Redistributable Package (64-bit version) must be installed on computer for correct work of Tesseract4.Vintasoft.x64.dll.


    By default the Tesseract OCR files are located in the "TesseractOcr" directory and the directory has the following structure:

    An instance of TesseractOcr class must be created for text recognition using Tesseract OCR. The default constructor (constructor without parameters) takes the directory "\TesseractOcr\" as the directory where are located Tesseract OCR files. To specify another directory is necessary to use the constructor with string parameter.

    Here is an example that shows how to create an instance of TesseractOcr class and specify the directory where are located Tesseract OCR files:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Ocr.Tesseract
    
    Dim tesseractOcrDllPath As String = "D:\Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr"
    Dim tesseractOcr As New Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr(tesseractOcrDllPath)
    
    ' ...
    
    tesseractOcr.Dispose()
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Ocr.Tesseract
    
    string tesseractOcrDllPath = @"D:\Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr";
    Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr tesseractOcr = 
        new Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr(tesseractOcrDllPath);
    
    // ...
    
    tesseractOcr.Dispose();
                    
    


    Initialize an instance of TesseractOcr class

    After an instance of TesseractOcr class is created it is necessary to call TesseractOcr.Init method to initialize the instance. The TesseractOcr.Init method allows to specify the the default language for text recognition.

    Tesseract OCR 4.0 allows to recognize text in more than 100 languages. The installation package of the SDK by default includes only the English language dictionary.

    The following table shows a complete list of languages supported by Tesseract OCR 4.0 and 3.04 and links for downloading the language files:
    Language Tesseract 4.0 (fast) dictionary - RECOMMENDED Tesseract 4.0 (best) dictionary Tesseract 4.0 (standard) dictionary Tesseract 3.04 dictionary
    Afrikaans Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Amharic Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Arabic Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Assamese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Azerbaijani Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Azerbaijani Cyrilic Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Belarusian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Bengali Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tibetan Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Bosnian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Bre Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Bulgarian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Catalan Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Cebuano Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Czech Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Chinese Simplified Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Chinese Simplified vertical Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Chinese Traditional Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Chinese Traditional vertical Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Cherokee Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Cos Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Welsh Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Danish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Danish Fraktur - - Tesseract 4.0 (standard) Tesseract 3.04
    German Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    German Fraktur - - Tesseract 4.0 (standard) Tesseract 3.04
    Div Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Dzongkha Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Greek Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    English Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    English Middle Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Esperanto Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Math Equation Detection Module - - Tesseract 4.0 (standard) Tesseract 3.04
    Estonian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Basque Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Fao Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Persian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Fil Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Finnish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    French Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Frankish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    French Middle Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Fry Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Gla Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Irish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Galician Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Greek Ancient Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Gujarati Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Haitian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Hebrew Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Hindi Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Croatian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Hungarian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Hye Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Inuktitut Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Indonesian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Icelandic Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Italian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Italian Old Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Javanese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Japanese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Japanese vertical Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Kannada Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Georgian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Georgian Old Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Kazakh Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Central Khmer Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Kirghiz Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Kmr Tesseract 4.0 (fast) Tesseract 4.0 (best) - -
    Korean Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Korean vertical Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Kurdish - - Tesseract 4.0 (standard) Tesseract 3.04
    Kurdish Arabic - - Tesseract 4.0 (standard) -
    Lao Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Latin Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Latvian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Lithuanian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Ltz Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Malayalam Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Marathi Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Macedonian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Maltese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Mon Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Mri Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Malay Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Burmese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Nepali Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Dutch Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Norwegian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Oci Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Oriya Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Osd Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Panjabi Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Polish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Portuguese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Pushto Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Que Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Romanian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Russian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Sanskrit Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Sinhala Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Slovakian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Slovak Fraktur - - Tesseract 4.0 (standard) Tesseract 3.04
    Slovenian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Snd Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Spanish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Spanish Castilian Old Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Albanian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Serbian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Serbian Latin Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Sun Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Swahili Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Swedish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Syriac Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tamil Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tat Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Telugu Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tajik Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tagalog - - Tesseract 4.0 (standard) Tesseract 3.04
    Thai Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Tigrinya Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Ton Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -
    Turkish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Uighur Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Ukrainian Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Urdu Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Uzbek Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Uzbek Cyrilic Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Vietnamese Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Yiddish Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) Tesseract 3.04
    Yor Tesseract 4.0 (fast) Tesseract 4.0 (best) Tesseract 4.0 (standard) -

    Important: Tesseract OCR 3.04 dictionaries are compatible with Tesseract OCR 4.

    Important: Tesseract OCR uses an image set with font symbols for learning of Tesseract OCR dictionary. In most cases image set for learning Tesseract OCR 4 dictionary is larger than image set for learning Tesseract OCR 3 dictionary. Due of this Tesseract OCR 4 dictionary provides better text recognition result than Tesseract OCR 3 dictionary but Tesseract OCR 3 dictionary may work faster than Tesseract OCR 4 dictionary. Please compare text recognition results and performance for choosing the best dictionary for your task.


    Here is an example that shows how to specify German language as main language to be used for text recognition:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Ocr
    ' - Vintasoft.Imaging.Ocr.Tesseract
    
    ' create the OCR engine
    Using tesseractOcr As New Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr()
        ' specify that OCR engine will recognize German text
        Dim language As Vintasoft.Imaging.Ocr.OcrLanguage = Vintasoft.Imaging.Ocr.OcrLanguage.German
        ' create the OCR engine settings
        Dim settings As New Vintasoft.Imaging.Ocr.Tesseract.TesseractOcrSettings(language)
        ' initialize the OCR engine
        tesseractOcr.Init(settings)
    
        ' ...
    
        ' shutdown the OCR engine
        tesseractOcr.Shutdown()
    End Using
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Ocr
    // - Vintasoft.Imaging.Ocr.Tesseract
    
    // create the OCR engine
    using (Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr tesseractOcr = 
        new Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr())
    {
        // specify that OCR engine will recognize German text
        Vintasoft.Imaging.Ocr.OcrLanguage language = Vintasoft.Imaging.Ocr.OcrLanguage.German;
        // create the OCR engine settings
        Vintasoft.Imaging.Ocr.Tesseract.TesseractOcrSettings settings = 
            new Vintasoft.Imaging.Ocr.Tesseract.TesseractOcrSettings(language);
        // initialize the OCR engine
        tesseractOcr.Init(settings);
    
        // ...
    
        // shutdown the OCR engine
        tesseractOcr.Shutdown();
    }
                    
    


    Parameters of Tesseract OCR

    Tesseract OCR 4.0 has a lot of parameters.

    You can get the value of any parameter using TesseractOcr.GetVariable method.
    You can set the value of any parameter using TesseractOcr.SetVariable method.

    Here is an example that shows how to use the parameter "char whitelist":
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Ocr
    ' - Vintasoft.Imaging.Ocr.Tesseract
    
    Class TesseractOcrSetVariableExample
        ''' <summary>
        ''' Specifies that text contains only the limited set of characters and
        ''' recognizes the text in image.
        ''' </summary>
        ''' <param name="filename">The name of file, which stores images with text.</param>
        Public Shared Sub OcrImageWithDigits(filename As String)
            ' create an image collection
            Using images As 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 tesseractOcr As New Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr()
                    System.Console.WriteLine("Initialize OCR engine...")
                    ' init the Tesseract OCR engine
                    tesseractOcr.Init(New Vintasoft.Imaging.Ocr.OcrEngineSettings(Vintasoft.Imaging.Ocr.OcrLanguage.English))
    
                    ' set the "white list" of recognizing characters
                    tesseractOcr.SetVariable("tessedit_char_whitelist", "01234567890")
    
                    ' for each image
                    For Each image As Vintasoft.Imaging.VintasoftImage In images
                        System.Console.WriteLine("Recognize the image...")
    
                        ' recognize text in image
                        Dim ocrResult As Vintasoft.Imaging.Ocr.Results.OcrPage = tesseractOcr.Recognize(image)
    
                        ' output the recognized text
    
                        System.Console.WriteLine("Page Text:")
                        System.Console.WriteLine(ocrResult.GetText())
                        System.Console.WriteLine()
                    Next
    
                    ' shutdown the Tesseract OCR engine
                    tesseractOcr.Shutdown()
                End Using
    
                ' free images
                images.ClearAndDisposeItems()
            End Using
        End Sub
    End Class
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Ocr
    // - Vintasoft.Imaging.Ocr.Tesseract
    
    class TesseractOcrSetVariableExample
    {
        /// <summary>
        /// Specifies that text contains only the limited set of characters and
        /// recognizes the text in image.
        /// </summary>
        /// <param name="filename">The name of file, which stores images with text.</param>
        public static void OcrImageWithDigits(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
                    tesseractOcr.Init(new Vintasoft.Imaging.Ocr.OcrEngineSettings(
                        Vintasoft.Imaging.Ocr.OcrLanguage.English));
    
                    // set the "white list" of recognizing characters
                    tesseractOcr.SetVariable(
                        "tessedit_char_whitelist", "01234567890");
    
                    // for each image
                    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();
            }
        }
    }