Skip to content

Error on creating TesseractEngine #673

Open
@Vernizze

Description

Hi!

I'm starting with Tesseract and have this code, that runs very well on Windows:

using (var engine = new TesseractEngine("tessdata", "por"))
{            
    var image = Pix.LoadFromFile(filePath);

    var page = engine.Process(image);

    text = page.GetText();
}

But I need run this one on Linux, most specifically on Mint distribution, and I use in this form:

using (var engine = new TesseractEngine("./tessdata", "por"))
{            
    var image = Pix.LoadFromFile(filePath);

    var page = engine.Process(image);

    text = page.GetText();
}

And I receive this error in the 'new TesseractEngine' line:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.ArgumentNullException.Throw(String paramName)
at System.IO.Path.Combine(String path1, String path2)
at InteropDotNet.LibraryLoader.InternalLoadLibrary(String baseDirectory, String platformName, String fileName)
at InteropDotNet.LibraryLoader.CheckExecutingAssemblyDomain(String fileName, String platformName)
at InteropDotNet.LibraryLoader.LoadLibrary(String fileName, String platformName)
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.CreateInstanceT
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, IEnumerable1 configFiles, IDictionary2 initialOptions, Boolean setOnlyNonDebugVariables)
at Tesseract.TesseractEngine..ctor(String datapath, String language)
at TesteConversaoPdfParaImagem.Program.ReadImage(String prefix, String filePath, String resultFileName, Boolean isSingleblock) in C:\Users\carlo\source\repos\TesteConversaoPdfParaImagem\TesteConversaoPdfParaImagem\Program.cs:line 127
at TesteConversaoPdfParaImagem.Program.Main(String[] args) in C:\Users\carlo\source\repos\TesteConversaoPdfParaImagem\TesteConversaoPdfParaImagem\Program.cs:line 53

Do you help me with this, please?

Thanks a lot, guys! :)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions