Ejemplo n.º 1
0
 /// <summary>
 /// Initializes instance of tesseract if it haven't been already
 /// initialized or it have been disposed and sets all the required
 /// properties.
 /// </summary>
 /// <param name="outputFormat">
 /// selected
 /// <see cref="OutputFormat"/>
 /// for tesseract
 /// </param>
 public virtual void InitializeTesseract(OutputFormat outputFormat)
 {
     if (GetTesseractInstance() == null || TesseractOcrUtil.IsTesseractInstanceDisposed(GetTesseractInstance())
         )
     {
         tesseractInstance = TesseractOcrUtil.InitializeTesseractInstance(IsWindows(), GetTessData(), GetLanguagesAsString
                                                                              (), GetTesseract4OcrEngineProperties().GetPathToUserWordsFile());
     }
     GetTesseractInstance().SetVariable("tessedit_create_hocr", outputFormat.Equals(OutputFormat.HOCR) ? "1" :
                                        "0");
     GetTesseractInstance().SetVariable("user_defined_dpi", "300");
     if (GetTesseract4OcrEngineProperties().GetPathToUserWordsFile() != null)
     {
         GetTesseractInstance().SetVariable("load_system_dawg", "0");
         GetTesseractInstance().SetVariable("load_freq_dawg", "0");
         GetTesseractInstance().SetVariable("user_words_suffix", GetTesseract4OcrEngineProperties().GetDefaultUserWordsSuffix
                                                ());
         GetTesseractInstance().SetVariable("user_words_file", GetTesseract4OcrEngineProperties().GetPathToUserWordsFile
                                                ());
     }
     TesseractOcrUtil.SetTesseractProperties(GetTesseractInstance(), GetTessData(), GetLanguagesAsString(), GetTesseract4OcrEngineProperties
                                                 ().GetPageSegMode(), GetTesseract4OcrEngineProperties().GetPathToUserWordsFile());
 }