←Select platform

OcrPageType Enumeration

Summary

The type of the page's RasterImage to get.

Syntax

C#
VB
Java
Objective-C
C++
[SerializableAttribute()] 
public enum OcrPageType   

<SerializableAttribute()> 
Public Enum OcrPageType  

typedef NS_ENUM(NSInteger, LTOcrPageType) 

public enum OcrPageType 

[SerializableAttribute()] 
public enum class OcrPageType   

Members

ValueMemberDescription
0Current The current image, this is a clone of the original image and has the same properties as the original image used to create the page.
1Processing The processing image is created internally by the OCR engine and is passed to the zoning and recognition routines. This image is always black/white with uniform resolution.
2Original The original image reference. This image is used by the OCR engine internally and should not be disposed. The original image is not null when this page is created by adding an image from a file, URL or stream or when the value of the "Recognition.ShareOriginalImage" setting is true. Otherwise, the engine will return a null reference for this value.
Remarks

Each IOcrPage contains two versions of the image used to create it: the current and an optional processing version. The processing version usually black/white and has uniform resolution (if the original image is FAX for example) and it gets passed to the internal OCR engine during the zoning and recognition process. The AutoPreprocess method also uses the B/W image to determine if the page is inverted, skewed or has an orientation; however, it applies the correction to both the current and processing images.

You can use IOcrPage.GetRasterImage(OcrPageType) to get a copy of either of these images.

You cannot set the processing image of a page; it is created automatically by the engine. This is why there is no IOcrPage.SetRasterImage(OcrPageType pageType) method.

If the original image is black and white and has uniform vertical and horizontal resolution, then the engine will not create a processing image, in other words, IOcrPage.GetRasterImage(OcrPageType.Current) and IOcrPage.GetRasterImage(OcrPageType.Processing) will return identical RasterImage objects.

If the original image has different horizontal and vertical resolution, such as a FAX image, the processing page will be have be resized to have uniform resolution.

The LEADTOOLS C# and VB .NET Main OCR demos (Examples\DotNet\CS\OcrMainDemo and Examples\DotNet\VB\OcrMainDemo) have an option in the page menu to toggle between showing the current (default) or processing image of each page.

Example

This example will add a colored 24 bits/pixel image to the OCR engine, then gets the current and processing version of it and show their properties.

C#
VB
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 OcrPageTypeExample() 
{ 
   OcrEngineType engineType = OcrEngineType.LEAD; 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(engineType, false)) 
   { 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Load an image as 24-bpp 
      RasterImage image = ocrEngine.RasterCodecsInstance.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"), 24, CodecsLoadByteOrder.Bgr, 1, 1); 
      // Show the original image properties 
      Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel); 
      System.Diagnostics.Debug.Assert(image.BitsPerPixel == 24); 
 
      // Create a page for it 
      using (IOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose)) 
      { 
         // Show the current OCR page size and color depth 
         using (image = ocrPage.GetRasterImage(OcrPageType.Current)) 
         { 
            Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel); 
            System.Diagnostics.Debug.Assert(image.BitsPerPixel == 24); 
         } 
 
         // Show the processing OCR page size and color depth 
         using (image = ocrPage.GetRasterImage(OcrPageType.Processing)) 
         { 
            Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel); 
            System.Diagnostics.Debug.Assert(image.BitsPerPixel == 1); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"; 
} 

Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Ocr 
Imports Leadtools.Forms 
Imports Leadtools.Document.Writer 
Imports Leadtools.WinForms 
Imports Leadtools.Drawing 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
 
Public Sub OcrPageTypeExample() 
   Dim engineType As OcrEngineType = OcrEngineType.LEAD 
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(engineType, False) 
      ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir) 
 
      ' Load an image as 24-bpp 
      Dim image As RasterImage = 
         ocrEngine.RasterCodecsInstance.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"), 24, CodecsLoadByteOrder.Bgr, 1, 1) 
 
      ' Show the original image properties 
      Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel) 
      System.Diagnostics.Debug.Assert(image.BitsPerPixel = 24) 
 
      ' Create a page for it 
      Using ocrPage As IOcrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose) 
         ' Show the current OCR page size and color depth 
         image = ocrPage.GetRasterImage(OcrPageType.Current) 
         Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel) 
         System.Diagnostics.Debug.Assert(image.BitsPerPixel = 24) 
 
 
         ' Show the processing OCR page size and color depth 
         image = ocrPage.GetRasterImage(OcrPageType.Processing) 
         Console.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel) 
         System.Diagnostics.Debug.Assert(image.BitsPerPixel = 1) 
 
      End Using 
   End Using 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
   Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime" 
End Class 

Requirements

Target Platforms

Help Version 20.0.2018.6.20
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly