标签:create index isnull com cto als http cli sse
_ocr = new Tesseract(@".\", "eng", OcrEngineMode.TesseractLstmCombined);
纠结了有几个星期,最后终于试出来了。
总结原因有N,如下:
path = @"C:\myTools\Tess“ 后面需要加上 \,
如果path= @"C:\myTools\Tess\", 那么文件应该放在一个名叫tessdata的子文件夹内,而不是直接放在path的目录下。
刚开始我下载了最新的traindata放在文件夹下面,不好使呀,随后找到了正确的版本,才成功
emgu版本号:3.4.3 所需要的数据版本路径如下
string path = @"C:\myTools\Tess\"; _ocr = new Tesseract(path, "eng", OcrEngineMode.TesseractLstmCombined);
从Emgu官网下载的程序包里面的例程。
http://www.emgu.com/wiki/index.php/Main_Page
关键代码区域如下
private void InitOcr(String path, String lang, OcrEngineMode mode) { try { if (_ocr != null) { _ocr.Dispose(); _ocr = null; } if (String.IsNullOrEmpty(path)) path = "."; TesseractDownloadLangFile(path, lang); TesseractDownloadLangFile(path, "osd"); //script orientation detection String pathFinal = path.Length == 0 || path.Substring(path.Length - 1, 1).Equals(Path.DirectorySeparatorChar.ToString()) ? path : String.Format("{0}{1}", path, System.IO.Path.DirectorySeparatorChar); _ocr = new Tesseract(pathFinal, lang, mode); } catch (Exception e) { _ocr = null; System.Diagnostics.Debug.Print(e.Message, "Failed to initialize tesseract OCR engine"); } }
private static void TesseractDownloadLangFile(String folder, String lang) { String subfolderName = "tessdata"; String folderName = System.IO.Path.Combine(folder, subfolderName); if (!System.IO.Directory.Exists(folderName)) { System.IO.Directory.CreateDirectory(folderName); } String dest = System.IO.Path.Combine(folderName, String.Format("{0}.traineddata", lang)); if (!System.IO.File.Exists(dest)) using (System.Net.WebClient webclient = new System.Net.WebClient()) { String source = String.Format("https://github.com/tesseract-ocr/tessdata/blob/4592b8d453889181e01982d22328b5846765eaad/{0}.traineddata?raw=true", lang); Console.WriteLine(String.Format("Downloading file from ‘{0}‘ to ‘{1}‘", source, dest)); webclient.DownloadFile(source, dest); Console.WriteLine(String.Format("Download completed")); } }
标签:create index isnull com cto als http cli sse
原文地址:https://www.cnblogs.com/jiceberg420/p/10697403.html