【问题标题】:PDF Ocr with IronOcr throws SEHException when running read运行读取时带有 IronOcr 的 PDF Ocr 抛出 SEHException
【发布时间】:2025-12-04 19:40:02
【问题描述】:
        var ocr = new IronOcr.IronTesseract();
        using (var input = new IronOcr.OcrInput( ) )
        {
            input.AddPdfPages( "./20160026957.pdf", new[] { 1 } );
            input.Deskew();
            //input.DeNoise();
            var contents = ocr.Read( input );
            Console.Write( contents.Text );
        }

ocr.Read() 抛出 SEHException。堆栈跟踪如下:

Fatal error. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at IronOcr.Extensions.scotjg.xqdvnf(System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef)
   at IronOcr.Extensions.scotjh.qjuwqn(System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef)
   at IronOcr.Extensions.scotji.pykdtk()
   at IronOcr.Extensions.scotjz.hmqdoj(IronOcr.Extensions.scotji)
   at IronOcr.IronTesseract.mwlewb(IronOcr.OcrResult, IronOcr.Extensions.scotkf, System.Collections.Generic.IEnumerable`1<IronOcr.Extensions.scotjz>, imgsra, Int32)
   at IronOcr.IronTesseract.mwlewb(IronOcr.OcrInput, System.Nullable`1<System.Drawing.Rectangle>)
   at IronOcr.IronTesseract.Read(IronOcr.OcrInput)
   at Preprocessing.Program+<Main>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
   at Preprocessing.Program.Main(System.String[])
   at Preprocessing.Program.<Main>(System.String[])

任何人都可以提供任何指导吗?

【问题讨论】:

  • 错误 0x80004005 是未指定的窗口错误。我怀疑构建说明存在问题。通常这样的错误是由于 dll 的编译方式不同,如 x86、x32、x64。可能你需要AnyCpu。正在找到所有 dll,但 dll 之间存在一些不兼容问题。
  • 尝试添加pdf的完整路径名。

标签: c# ocr


【解决方案1】:

我知道这很旧,但我在某些机器上遇到了同样的问题,我不知道原因,但更换引擎为我解决了这个问题:

ocr.Configuration.EngineMode = IronOcr.TesseractEngineMode.TesseractOnly;

【讨论】:

    最近更新 更多