public static class OcrEngineManager The OcrEngineManager class and its methods are your entry point to using the Leadtools.Ocr class library.
This class provides the methods you need to create an object of the IOcrEngine interface. Afterwards, you can use the properties and methods of this interface to perform your OCR tasks.
Based on the engine type passed to the CreateEngine methods, OcrEngineManager will load the OCR engine defined in one of the supporting assemblies and return an interface to IOcrEngine. Use this interface and its included types to start using the Leadtools.Ocr class library. For more information about the engine types, refer to OcrEngineType.
The CreateEngine method lets you create an instance of IOcrEngine, loading the corresponding Leadtools.Ocr.[EngineName].dll assembly using the .NET System.Reflection.Assembly.Load(string assemblyString) method. You cannot unload this assembly once it has been successfully loaded.
The LEADTOOLS OCR Module - LEAD Engine is now thread-safe and so the "THUNK" mechanism is no longer required.
This example shows how to OCR documents using multiple threads.
using Leadtools;using Leadtools.Ocr;using Leadtools.Document.Writer;using Leadtools.Codecs;public void MultiThreadedOcrExample(){// The image file names we are going to OCR and convert to PDFstring[] tifFileNames ={Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr2.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr3.tif"),Path.Combine(LEAD_VARS.ImagesDir, "Ocr4.tif")};int threadCount = tifFileNames.Length;// Create the threadThread[] threads = new Thread[threadCount];AutoResetEvent[] waitHandles = new AutoResetEvent[threadCount];for (int i = 0; i < threadCount; i++){threads[i] = new Thread(new ParameterizedThreadStart(MyThreadProc));threads[i].Name = "OCR thread + " + i.ToString();waitHandles[i] = new AutoResetEvent(false);}Console.WriteLine("Starting the threads and waiting...");// Start the threadsfor (int i = 0; i < threadCount; i++){MyThreadData threadData = new MyThreadData();threadData.ImageFileName = tifFileNames[i];threadData.WaitHandle = waitHandles[i];threads[i].Start(threadData);}// Wait till all threads are doneWaitHandle.WaitAny(waitHandles);Console.WriteLine("All threads finished");}private struct MyThreadData{public string ImageFileName;public AutoResetEvent WaitHandle;}private void MyThreadProc(object data){// Grab the dataMyThreadData threadData = (MyThreadData)data;string imageFileName = threadData.ImageFileName;// Show a status messageConsole.WriteLine("Begin: {0}", imageFileName);// Create an instance of the OCR engine using. If you change the engine type from Advantage,// then the last parameter indicates the use of the LEADTOOLS Thunk Serverusing (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)){// Start the engine using default parametersocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);// Get the PDf file namestring pdfFileName = Path.ChangeExtension(imageFileName, "pdf");// Create an OCR documentusing (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()){// Add a page to the documentIOcrPage ocrPage = ocrDocument.Pages.AddPage(imageFileName, null);// Recognize the page// Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will// check and automatically auto-zones the pageocrPage.Recognize(null);// Save the document we have as PDFocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);}// Shutdown the engine// Note: calling Dispose will also automatically shutdown the engine if it has been startedocrEngine.Shutdown();}Console.WriteLine("End: {0}", imageFileName);// Singal the main threadthreadData.WaitHandle.Set();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime";}