Emgu CV,Tessdata-无法加载pol语言

问题描述 投票:0回答:1

我已经下载了EmguCV v4.2.0和tessdata文件夹并添加了语言,并将此文件夹粘贴到bin文件夹中。在tessdata文件夹中,我也有多种语言,包括eng和pol。

在C#中,我有这样的代码:

 using (ImageParser ip = new ImageParser(@"C:\Emgu\emgucv-windesktop 4.2.0.3662\bin\tessdata", "eng"))
 {
     if (ip.OcrImage("C:\\Users\\v-user1\\Pictures\\Saved Pictures\\bied.PNG") != string.Empty)
     {
         w.AddRange(ip?.Words.ToList<string>());
     }
 }

当我设置为“ eng”时,ImageParser正确创建,但是当我更改为“ pol”语言时,出现错误:

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

此错误的原因是什么?

c# tesseract emgucv
1个回答
0
投票

根据我的收集,您正试图加载到tessdata文件中,以便Tesseract在尝试检测文本时可以引用它。下面的方法是我过去使用的方法,对我来说效果很好。在早期版本的Emgucv中,setVariable和白名单功能不起作用,但是我不确定在以后的版本中是否已修复。

  public static void LoadOCREngine(String dataPath)
  {
     //create OCR engine
     _ocr = new Tesseract(dataPath, "eng", OcrEngineMode.TesseractCubeCombined);
     _ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");
  }
© www.soinside.com 2019 - 2024. All rights reserved.