Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, June 17, 2022 10:10:34 AM(UTC)
alexkoza

Groups: Registered
Posts: 2


I have the Leadtools Evaluation SDK. When I call OcrEngine.Startup(), I am getting the following exception: Leadtools.Ocr.OcrException: 'OCR engine initialization error, could not find the engine runtime'. Here is my code. It has been working successfully for the last few weeks. I have not been able to find anything about this exception online.

public List<string> GetText(string fileName)
{
SetLicense();

using (var engine = InitializeOcrEngine())
{
return GetText(engine, fileName).Select(page => page.Text).ToList();
}
}

private bool SetLicense()
{
var licenseIsSet = !RasterSupport.KernelExpired;
if (licenseIsSet)
{
return true;
}

try
{
RasterSupport.SetLicense(license, developerKey);

return true;
}
catch (Exception e)
{
Log.Error(e.Message);

throw;
}
}

private IOcrEngine InitializeOcrEngine()
{
var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD);
ocrEngine.Startup(null, null, null, null);
return ocrEngine;
}

private List<DocumentPageText> GetText(IOcrEngine ocrEngine, string fileName)
{
using (var documentFactory = DocumentFactory.LoadFromFile(fileName, new LoadDocumentOptions {FirstPageNumber = 1, LastPageNumber = -1}))
{
documentFactory.Text.OcrEngine = ocrEngine;

var pages = new List<DocumentPageText>();
foreach (var page in documentFactory.Pages)
{
var pageText = page.GetText();
pageText.BuildText();
pageText.BuildWords();
pages.Add(pageText);
}

return pages;
}
}
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, June 17, 2022 10:41:29 AM(UTC)
Marcus Andra

Groups: Registered, Manager, Tech Support, Administrators
Posts: 107

Was thanked: 9 time(s) in 9 post(s)

Hello,

You are likely running into an issue here due to the fourth parameter you are passing into the ocrEngine.Startup.

ocrEngine.Startup(null, null, null, null);
https://www.leadtools.co.../iocrengine-startup.html

The fourth parameter for this method looks for the path to where the OCR Runtime files are located. By default you can find the runtime file location in the following default installation location: C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime

Assuming the OCR Runtime files are in this directory, to fix your issue try changing the fourth parameter for this to:
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime");

Thanks,
Marcus Andra
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#3 Posted : Friday, June 17, 2022 12:24:52 PM(UTC)
alexkoza

Groups: Registered
Posts: 2


That worked, thank you.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.088 seconds.