-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on creating TesseractEngine #673
Comments
I am not expert but, its definitely about your path :D. |
Hi guys! I found the error. It's happen on the class 'InteropDotNet.LibraryLoader', at the line 86:
The code ` using System; namespace Tesseract.Internal
} ` And the problem has solved. But after this, the error change to this:
In the next week I expect return to see this new problem. Thank's for your help :) |
Thanks, I'll see if I can find some time this evening to put in a fix. If I
don't, feel free to create a push request with fix and I'll merge it in.
Sorry haven't been all that active lately, pretty much all my free time is
taken up with home Reno's/repairs.
…On Sun, 30 June 2024, 4:53 am Carlos Felippe Vernizze, < ***@***.***> wrote:
Hi guys!
I found the error. It's happen on the class 'InteropDotNet.LibraryLoader',
at the line 86:
var baseDirectory = Path.GetDirectoryName(executingAssembly.Location);
The code executingAssembly.Location return null and it's the cause of the
crash. I created a handler class called 'EnvironmentUtils.cs' in
'Tesseract.Internal' with this code:
` using System;
using System.IO;
using System.Reflection;
namespace Tesseract.Internal
{
internal static class EnvironmentUtils
{
public static string AppPath(Assembly assembly)
{
string appPath =
Path.GetDirectoryName(Path.GetDirectoryName(assembly?.Location));
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
return AppPath();
}
public static string AppPath()
{
string appPath;
appPath = Directory.GetCurrentDirectory();
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
appPath = Environment.CurrentDirectory;
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
appPath = Path.Combine(AppContext.BaseDirectory, "tessdata");
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
appPath = Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location));
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
appPath = AppDomain.CurrentDomain.BaseDirectory;
if (!string.IsNullOrWhiteSpace(appPath))
return appPath;
throw new ArgumentNullException("Application path not found");
}
}
} `
And the problem has solved. But after this, the error change to this:
Unhandled exception. System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.DllNotFoundException: Failed to find library "
libleptonica-1.82.0.so" for platform x64. at
InteropDotNet.LibraryLoader.LoadLibrary(String fileName, String
platformName) in
D:\git\tesseract\src\Tesseract\Internal\InteropDotNet\LibraryLoader.cs:line
57 at
InteropRuntimeImplementer.LeptonicaApiSignaturesInstance.LeptonicaApiSignaturesImplementation..ctor(LibraryLoader
loader) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void**
arguments, Signature sig, Boolean isConstructor) at
System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object
obj, Span1 copyOfArgs, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object
obj, Span1 copyOfArgs, BindingFlags invokeAttr) at
System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture) at
InteropDotNet.InteropRuntimeImplementer.CreateInstance[T]() in
D:\git\tesseract\src\Tesseract\Internal\InteropDotNet\InteropRuntimeImplementer.cs:line
45 at Tesseract.Interop.LeptonicaApi.Initialize() in
D:\git\tesseract\src\Tesseract\Interop\LeptonicaApi.cs:line 563 at
Tesseract.Interop.TessApi.Initialize() in
D:\git\tesseract\src\Tesseract\Interop\BaseApi.cs:line 583 at
Tesseract.Interop.TessApi.get_Native() in
D:\git\tesseract\src\Tesseract\Interop\BaseApi.cs:line 372 at
Tesseract.TesseractEngine..ctor(String datapath, String language,
EngineMode engineMode, IEnumerable1 configFiles, IDictionary2
initialOptions, Boolean setOnlyNonDebugVariables) in
D:\git\tesseract\src\Tesseract\TesseractEngine.cs:line 181 at
Tesseract.TesseractEngine..ctor(String datapath, String language) in
D:\git\tesseract\src\Tesseract\TesseractEngine.cs:line 37 at
TesteConversaoPdfParaImagem.Program.ReadImage(String prefix, String
filePath, String resultFileName, Boolean isSingleblock) in
C:\Users\carlo\source\repos\TesteConversaoPdfParaImagem\TesteConversaoPdfParaImagem\Program.cs:line
147 at TesteConversaoPdfParaImagem.Program.Extract(String pdfName, String
readedFilePath) in
C:\Users\carlo\source\repos\TesteConversaoPdfParaImagem\TesteConversaoPdfParaImagem\Program.cs:line
68 at TesteConversaoPdfParaImagem.Program.Main(String[] args) in
C:\Users\carlo\source\repos\TesteConversaoPdfParaImagem\TesteConversaoPdfParaImagem\Program.cs:line
14
In the next week I expect return to see this new problem.
Thank's for your help :)
—
Reply to this email directly, view it on GitHub
<#673 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB7HSCU24LUJLZFIBIQMADZJ37CFAVCNFSM6AAAAABJ6R2EHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGMYDAOJWG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hi!
I'm starting with Tesseract and have this code, that runs very well on Windows:
But I need run this one on Linux, most specifically on Mint distribution, and I use in this form:
And I receive this error in the 'new TesseractEngine' line:
Do you help me with this, please?
Thanks a lot, guys! :)
The text was updated successfully, but these errors were encountered: