簡體   English   中英

Tesseract ClickOnce部署失敗

[英]Tesseract ClickOnce Deployment fails

我正在將tesseract OCR識別用於一個小型研究項目。 在本地運行和測試可以正常工作。 不幸的是,當我使用Tesseract OCR .NET Wrapper時,部署(WPF ClickOnce-Deployment)存在問題。 運行程序時(安裝后),出現以下錯誤:

Exception has been thrown by the target of an invocation.
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at InteropDotNet.InteropRuntimeImplementer.CreateInstance[T]()
   at Tesseract.Interop.LeptonicaApi.Initialize()
   at Tesseract.Interop.TessApi.Initialize()
   at Tesseract.Interop.TessApi.get_Native()
   at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode)
   at WindowsContextTracker.Helpers.OcrEngine..ctor()
   at WindowsContextTracker.Helpers.OcrEngine.GetInstance()
   at WindowsContextTracker.Daemon.RunContextRecognition(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

我的代碼:

var path = @"C:\ProgramData\myProgram\tessdata";
_tEngine = new TesseractEngine(path, "eng", EngineMode.Default);

我嘗試了路徑的各種組合 (動態地,靜態地)。 在路徑的位置,有一個tessdata目錄,其中包含9個文件(eng.cube.bigrams,eng.traineddata等)。

我非常感謝您提供解決我的問題的任何提示。 謝謝!

不幸的是,我找不到解決我問題的好方法。 WPF ClickOnceDeployments始終存儲在用戶AppData中的“臨時”文件夾中。 這是文件夾,您還需要(手動)復制tessdata文件夾以使tesseract api正常工作。 然后,您也不再需要向tessdata文件夾添加路徑。 在我看來,這條道路似乎行不通...

這不是真正的解決方案,而是我發現使其運行的唯一方法。因此,如果您知道更好的方法,請告訴我!

編輯 :感謝Sicos1977(在Github上 ),我找到了第二個問題的解決方案。 他為我指出了Stackoverflow 頁面 ,我在其中學習了如何在安裝過程中將整個文件夾復制到安裝位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM