←Select platform

OcrAutoPreprocessPageCommand Enumeration

Summary
Performs page pre-processing commands
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum OcrAutoPreprocessPageCommand   
typedef NS_ENUM(NSInteger, LTOcrAutoPreprocessPageCommand) { 
 LTOcrAutoPreprocessPageCommandNone,  
 LTOcrAutoPreprocessPageCommandDeskew,  
 LTOcrAutoPreprocessPageCommandRotate,  
 LTOcrAutoPreprocessPageCommandInvert,  
 LTOcrAutoPreprocessPageCommandAll 
}; 
public enum OcrAutoPreprocessPageCommand 
[SerializableAttribute()] 
public enum class OcrAutoPreprocessPageCommand   
class OcrAutoPreprocessPageCommand(Enum): 
   Deskew = 0 
   Rotate = 1 
   Invert = 2 
   All = 3 
Members
ValueMemberDescription
0Deskew Automatic deskewing. If the image is skewed, the IOcrPage.AutoPreprocess method will try to deskew it
1Rotate Automatic rotation. If the image is rotated (its view perspective is anything other than top-left), the IOcrPage.AutoPreprocess method will auto orient it to top-left. This command is especially useful if the image upside-down.
2Invert Automatic inversion. If the image is black and white and is inverted (contains white on black data), the IOcrPage.AutoPreprocess method will automatically convert the image data to be black on white
3All Run all the commands (Deskew, Rotate, Invert)
Remarks

The OCR engine can perform a series of image pre-processing steps in order to enhance the quality of the image before starting its recognition.

Perform these image pre-processing steps by calling the IOcrPage.AutoPreprocess method. Call this method prior to calling IOcrPage.Recognize.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Forms.Common; 
using Leadtools.Document.Writer; 
using Leadtools.WinForms; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
public void AutoPreprocessExample() 
{ 
   string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Clean.tif"); 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Clean.pdf"); 
 
   // Create an instance of the engine 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // 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(); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Ocr Namespace

Help Version 23.0.2024.4.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.