The call to OcrEngine.Startup() accepts four parameters. Typically, the call is made as such:
Code:
ocrEngine.Startup(null, null, null, null)
This call uses default options. However, these fields can be customized based on development needs. We have information on the call and its parameters in our online documentation. This post serves as an overview and explanation.
https://www.leadtools.co.../iocrengine-startup.htmlThe four parameters are:
- An instance of RasterCodecs
- An instance of DocumentWriter
- A string representing the work directory
- A string representing the startup parameters
How is the RasterCodecs instance used?If "null" is specified, a RasterCodecs instance is created internally by the engine, although some properties of the object are modified to facilitate recognition. Specifically, the XResolution and YResolution are set to 300, and the DisplayDepth is set to auto-detect. These settings are typically recommended when loading a document for OCR. A custom instance of RasterCodecs can be used as this parameter, however, it is recommended to set the XResolution and YResolution values as stated.
Code:
rasterCodecsInstance.Options.RasterizeDocument.Load.XResolution = 300
rasterCodecsInstance.Options.RasterizeDocument.Load.YResolution = 300
rasterCodecsInstance.Options.Pdf.Load.DisplayDepth = 0
Note that an internally created instance of RasterCodecs will be automatically disposed of by the engine, however, one passed as a parameter will not.
https://www.leadtools.co...ocumentwriter-usage.htmlHow is the DocumentWriter instance used?If "null" is specified, a DocumentWriter instance is created internally by the engine. This internally generated DocumentWriter uses default values and is disposed of automatically. An initialized DocumentWriter with custom values can be passed in and used instead if the default values are insufficient.
https://www.leadtools.co...umentwriterinstance.htmlWhat is the work directory?The IOcrEngine creates multiple temporary files during the recognition and document generation process. The work directory specifies where those files should be created. If "null" is specified, then the engine uses %TEMP%, which is the temporary folder of the current logged in user. Note that while the engine does remove temporary files after the operation is complete, if the engine does not shut down properly, these files may persist. By specifying a directory, an application can ensure any extraneous temp files are removed and that the application has access rights to the folder.
What does the startup parameters represent?The startup parameters represents the path on disk to the OCR engine runtime files. If "null" is used, the default path based on the selected OCR engine is used.
For OcrEngineType.LEAD:
C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime
Note using the default path can facilitate development of proof-of-concepts on development machines where the SDK is installed. It's highly recommended this path be changed before deployment to accommodate the directory structure generated by your application instead of creating a new folder structure just to accommodate this value.
What are the runtime files?The runtime files are required by the OCR engine and need to be included with the application. If the runtime files are not present in the directory specified by the startup parameters, the engine will throw an exception. We have more information specifically for OCR files, including those specific to each engine type, included in our documentation on OCR Files to be Included with your Application.
https://www.leadtools.co...th-your-application.htmlEdited by moderator Wednesday, December 27, 2023 3:09:06 PM(UTC)
| Reason: Updated
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.