public bool IsStarted { get; }
true if this IOcrEngine has been started and is ready to be used, otherwise it is false.
The Startup method must be called before invoking any other methods or properties in this IOcrEngine.
To check if the engine is started, use the IsStarted property.
You must call Shutdown to shut down the engine and free the memory and resources used.
You can call the Startup method multiple times, only the first call will start the engine while subsequent calls will only increment an internal counter. You must call Shutdown for each Startup called.
The IOcrEngine interface implements IDisposable. It is highly recommended that you call Dispose (or use the using statement in C# or Using statement in VB) when creating the IOcrEngine instance. The Dispose method will automatically shut down the engine if it has been started.
using Leadtools;using Leadtools.Codecs;using Leadtools.Ocr;using Leadtools.Document.Writer;public void StartupEngineExample(){// Use RasterCodecs to load an image file// Note: You can let the engine load the image file directly as shown in the other examplesRasterCodecs codecs = new RasterCodecs();RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"));// Assume you copied the engine runtime files to C:\MyApp\Ocrstring engineDir = @"C:\MyApp\Ocr";// Store the engine work directory into a path inside our applicationstring workDir = @"C:\MyApp\OcrTemp";// Delete all files in the work directory in case the previous version of our application exited abnormally and// the engine did not get the chance to clean all of its temporary files (if any)Directory.Delete(workDir, true);// Re-create the work directoryDirectory.CreateDirectory(workDir);// Create an instance of the engineusing (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)){// Show that the engine has not been started yetConsole.WriteLine("Before calling Startup, IsStarted = " + ocrEngine.IsStarted);// Start the engine using our parameters// Since we already have a RasterCodecs object, we can re-use it to save memory and resourcesocrEngine.Startup(codecs, null, workDir, engineDir);// Make sure the engine is using our working directoryConsole.WriteLine("workDir passed is {0}, the value of WorkDirectory after Startup is {1}", workDir, ocrEngine.WorkDirectory);// Show that the engine has started fineConsole.WriteLine("After calling Startup, EngineType is {0}, IsStarted = {1}", ocrEngine.EngineType, ocrEngine.IsStarted);// Maks sure the engine is using our own version of RasterCodecsDebug.Assert(codecs == ocrEngine.RasterCodecsInstance);// Create a page from the raster image as page to the documentIOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose);// image belongs to the page and will be dispose when the page is disposed// 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);// Create a file based documentusing (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument(null, OcrCreateDocumentOptions.AutoDeleteFile)){// Add the pageocrDocument.Pages.Add(ocrPage);// No need for the page anymoreocrPage.Dispose();// Save the document we have as PDFstring pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf");ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);}// Shutdown the engine// Note: calling Dispose will also automatically shutdown the engine if it has been startedocrEngine.Shutdown();}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}