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



command
The preprocessing command to perform.
callback
Optional callback to show operation progress.
command
The preprocessing command to perform.
callback
Optional callback to show operation progress.
Performs automatic image processing clean up on the image to enhance the quality of the page before beginning recognition.

Syntax

Visual Basic (Declaration) 
Overridable Sub AutoPreprocess( _
   ByVal command As OcrAutoPreprocessPageCommand, _
   ByVal callback As OcrProgressCallback _
) 
Visual Basic (Usage)Copy Code
Dim instance As IOcrPage
Dim command As OcrAutoPreprocessPageCommand
Dim callback As OcrProgressCallback
 
instance.AutoPreprocess(command, callback)
C# 
virtual void AutoPreprocess( 
   OcrAutoPreprocessPageCommand command,
   OcrProgressCallback callback
)
C++/CLI 
virtual void AutoPreprocess( 
   OcrAutoPreprocessPageCommand command,
   OcrProgressCallback^ callback
) 

Parameters

command
The preprocessing command to perform.
callback
Optional callback to show operation progress.

Example

Visual BasicCopy Code
Public Sub AutoPreprocessExample()
   ' 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")
   Dim tifFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Clean.tif"
   Dim pdfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Clean.pdf"

   ' 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)

      ' Create an OCR document
      Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
         ' Add this image to the document
         Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)

         ' Auto-preprocess it
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, Nothing)
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Invert, Nothing)
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Rotate, Nothing)

         ' Recognize it and save it as PDF
         ocrPage.Recognize(Nothing)
         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 AutoPreprocessExample() 

   // 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"); 
   string tifFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Clean.tif"; 
   string pdfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Clean.pdf"; 
 
   // 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); 
 
      // Create an OCR document 
      using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add this image to the document 
         IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, null); 
 
         // Auto-preprocess it 
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, null); 
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Invert, null); 
         ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Rotate, null); 
 
         // Recognize it and save it as PDF 
         ocrPage.Recognize(null); 
         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

Use this method to deskew, rotate or invert the image according to command. By performing auto pre-processing on a page, you can improve the image quality of draft mode faxes.

Use the OcrProgressCallback to show the operation progress or to abort it. For more information and an example, refer to OcrProgressCallback.

Call this method prior to calling IOcrPage.Recognize or RecognizeText.

Requirements

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

See Also

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