Performs automatic image processing clean up on the image to enhance the quality of the page before beginning recognition.
Syntax
Parameters
- command
- The preprocessing command to perform.
- callback
- Optional callback to show operation progress.
Example
Visual Basic | Copy Code |
---|
Public Sub AutoPreprocessExample()
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"
Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)
Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)
ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Deskew, Nothing)
ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Invert, Nothing)
ocrPage.AutoPreprocess(OcrAutoPreprocessPageCommand.Rotate, Nothing)
ocrPage.Recognize(Nothing)
ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)
End Using
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
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also