wpf Tesseract 3.02 无法加载 DLL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20793799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:18:16  来源:igfitidea点击:

Tesseract 3.02 Unable to load DLL

c#.netwpfdllwrapper

提问by George Chondrompilas

I'm trying to create a simple OCR program using Tesseract .Net wrapper for tesseract-ocr. I tried the sample project and it worked like a charm. The problem is, when I run my wpf project an Unable to load DLL 'libtesseract302': The specified module could not be found.error occurs Nothing to do with the code. I tried Dependency Walker ad it says that I am missing 3 DLLs. They seem to be Windows DLLs but they don't exist here: Windows API SetsAny idea what's going on?

我正在尝试使用 Tesseract .Net 包装器为 tesseract-ocr创建一个简单的 OCR 程序。我尝试了示例项目,它就像一个魅力。问题是,当我运行我的 wpf 项目Unable to load DLL 'libtesseract302': The specified module could not be found.时,发生错误与代码无关。我尝试了 Dependency Walker 广告,它说我缺少 3 个 DLL。它们似乎是 Windows DLL,但在此处不存在:Windows API 集知道发生了什么吗?

EDIT:

编辑:

I changed the target framework to 4 from 4.5, and there is nothing wrong with these DLLs now (the example project which is working perfectly is using NET Framework 4.0).

我将目标框架从 4.5 更改为 4,现在这些 DLL 没有任何问题(运行良好的示例项目使用的是 NET Framework 4.0)。

Now the problem is: Failed to initialise Tesseract Engine. Here is my simple code if that helps:

现在的问题是:Failed to initialise Tesseract Engine。如果有帮助,这是我的简单代码:

        try
        {
            using (TesseractEngine engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
            {
                using (Pix img = Pix.LoadFromFile(filename))
                {
                    using (Tesseract.Page page = engine.Process(img))
                    {
                        text = page.GetText();
                    }
                }
            }

        }
        catch (Exception ex)
        {
            text = ex.Message;
        }
        finally
        {
            conv_text_tb.Text = text;
        }

采纳答案by George Chondrompilas

Okay I found out the fix to that error. I changed the Copy to Output Directoryproperty of the DLL files and the files located in the tessdata folder to Copy Always. It's working perfectly now.

好的,我找到了该错误的修复方法。我Copy to Output Directory将 DLL 文件和位于 tessdata 文件夹中的文件的属性更改为Copy Always. 它现在工作得很好。