Leadtools.Forms.Ocr Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
IOcrEngine Interface
See Also  Members   Example
Leadtools.Forms.Ocr Namespace : IOcrEngine Interface



Provides support for OCR functionality in LEADTOOLS.

Syntax

Visual Basic (Declaration) 
Public Interface IOcrEngine 
Visual Basic (Usage)Copy Code
Dim instance As IOcrEngine
C# 
public interface IOcrEngine 
C++/CLI 
public interface class IOcrEngine 

Example

The following example will convert an image file to a PDF document.

Visual BasicCopy Code
Public Sub OcrEngineExample()
   ' Unlock the support needed for LEADTOOLS Plus OCR engine
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here")
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here")
   ' Create an instance of the engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
      ' Start the engine using default parameters
      ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)

      Dim tifFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"
      Dim pdfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"

      ' Create an OCR document
      Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()

         ' Add a page to the document
         Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)

         ' Recognize the page
         ' Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will
         ' check and automatically auto-zones the page
         ocrPage.AutoZone(Nothing)
         ocrPage.Recognize(Nothing)

         ' Save the document we have as PDF
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)
      End Using

      ' Shutdown the engine
      ' Note: calling Dispose will also automatically shutdown the engine if it has been started
      ocrEngine.Shutdown()
   End Using
End Sub
C#Copy Code
public void OcrEngineExample() 

   // Unlock the support needed for LEADTOOLS Plus OCR engine 
   RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here"); 
   RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here"); 
   // Create an instance of the engine 
   using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, null); 
 
      string tifFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; 
      string pdfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"; 
 
      // Create an OCR document 
      using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add a page to the document 
         IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, 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 page 
         ocrPage.AutoZone(null); 
         ocrPage.Recognize(null); 
 
         // Save the document we have as PDF 
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null); 
      } 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
}

Remarks

The IOcrEngine interface is your application entry point to the OCR functionality provided by LEADTOOLS.

LEADTOOLS OCR class library uses various interfaces to perform various OCR functions. These interfaces group logically related operations and encapsulates them from the rest of the toolkit. By using interfaces, LEADTOOLS ensures that you can use an engine-independent approach when programming your OCR-based application. At any time you can switch the engine type and ensure that your program will continue to function correctly. (Providing you have used the various "GetSupported" and "IsSupported" methods when dealing with engine-specific capabilities).

Obtain an instance of IOcrEngine by calling the OcrEngineManager.CreateEngine method with the appropriate engine type.

Once an instance is obtained, use the members of the IOcrEngine to perform various OCR tasks. OCR functions are grouped into "managers". Through these managers, you can create OCR documents (and add pages to these documents), perform zoning, recognition and saving the result documents. These managers are standard .NET interfaces with the implementation hidden inside the corresponding engine assembly. The following table lists the various "managers" and their main functionality:
MemberDescription
DocumentManager memberAllows you to create IOcrDocument objects that encapsulate an OCR'ed document. Each IOcrDocument contains an IOcrDocument.Pages property that is an implementation of standard .NET collection of IOcrPage objects. Use this member to add, remove or update image (raster) pages in the OCR document. Pages can be image files on disk, memory or even in a remote URL. Any file format supported by LEADTOOLS (TIFF, JPEG, BMP, etc) can be loaded into the OCR document. Once the image is loaded to the document, use the various IOcrPage methods to zone the page (or pages) in preparation to be recognized and saved as a document. For more information refer to IOcrDocument, IOcrPageCollection and IOcrPage. Once you are done with adding and preparing the pages, you can use the save methods of the IOcrDocument object to save the document into its final format. LEADTOOLS supports saving to various standard document formats such as PDF, Microsoft Word, HTML and several others. You can use the IOcrDocumentManager.GetSupportedFormats method to query the document formats supported by this engine instance. For more information, refer to IOcrDocumentManager, IOcrDocument and DocumentFormat.
ZoneManager memberProvides support for determining the various zone types, recognition modules and fill methods supported by this engine type. For more information, refer to IOcrZoneManager, OcrZoneType, OcrZoneRecognitionModule and OcrZoneFillMethod.
AutoRecognizeManager memberProvides support for one shot "fire and forget" approach to OCR. The methods of this interface will let you create a result document from an image file on disk with optional progress and status monitors. For more information, refer to IOcrAutoRecognizeManager.
LanguageManager memberProvides access to the language environment used by the OCR engine. You can use the methods and properties of this member to set the character set used by the OCR engine as well as spell correction. For more information, refer to IOcrLanguageManager.
SpellCheckManager memberAllows you to enable/disable the spell checking system as well to maintain language and user dictionaries. Also lets you set up a global callback for manual word or line verification when performing a recognition operation.
SettingManager memberEach OCR engine supported by LEADTOOLS has additional options and functionalities that can be accessed through this member. After setting up the engine, you can quickly save and later load the settings using the SettingManager. For more information, refer to IOcrSettingManager.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

IOcrEngine requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features