LEADTOOLS Support
Document
Document SDK Questions
OCR engine initialization error, could not find the engine runtime
#1
Posted
:
Friday, June 17, 2022 10:10:34 AM(UTC)
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;
}
}
#2
Posted
:
Friday, June 17, 2022 10:41:29 AM(UTC)
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.htmlThe 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.
#3
Posted
:
Friday, June 17, 2022 12:24:52 PM(UTC)
Groups: Registered
Posts: 2
LEADTOOLS Support
Document
Document SDK Questions
OCR engine initialization error, could not find the engine runtime
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.