Leadtools.Forms.Ocr Namespace : OcrPageType Enumeration |
[SerializableAttribute()] public enum OcrPageType : System.Enum, System.IComparable, System.IConvertible, System.IFormattable
'Declaration <SerializableAttribute()> Public Enum OcrPageType Inherits System.Enum Implements System.IComparable, System.IConvertible, System.IFormattable
'Usage Dim instance As OcrPageType
[SerializableAttribute()] public enum OcrPageType : System.IComparable, System.IConvertible, System.IFormattable
enum LTOcrPageType
public enum OcrPageType
Leadtools.Forms.Ocr.OcrPageType = function() { }; Leadtools.Forms.Ocr.OcrPageType.prototype = {
Current = 0x00000000, Processing = 0x00000001, Original = 0x00000002, };
[SerializableAttribute()] public enum class OcrPageType : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable
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 Leadtools.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.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms.Ocr Imports Leadtools.Forms Imports Leadtools.Forms.DocumentWriters Imports Leadtools.WinForms Imports Leadtools.ImageProcessing.Core Imports Leadtools.Drawing Private Shared Sub OcrPageTypeExample() Dim engineType As OcrEngineType = OcrEngineType.Advantage Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(engineType, False) ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir) Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument() Dim ocrPage As IOcrPage ' Load an image as 24-bpp Using image As RasterImage = ocrDocument.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) ' Add it to the OCR engine ocrPage = ocrDocument.Pages.AddPage(image, Nothing) End Using ' Show the current OCR page size and color depth Using image As RasterImage = 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) End Using ' Show the processing OCR page size and color depth Using image As RasterImage = 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 Using End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" Public Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 18\Bin\Common\OcrAdvantageRuntime" End Class
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms.Ocr; using Leadtools.Forms; using Leadtools.Forms.DocumentWriters; using Leadtools.WinForms; using Leadtools.Drawing; private static void OcrPageTypeExample() { OcrEngineType engineType = OcrEngineType.Advantage; using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(engineType, false)) { ocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir); using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) { IOcrPage ocrPage; // Load an image as 24-bpp using (RasterImage image = ocrDocument.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); // Add it to the OCR engine ocrPage = ocrDocument.Pages.AddPage(image, null); } // Show the current OCR page size and color depth using (RasterImage 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 (RasterImage 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 OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 18\Bin\Common\OcrAdvantageRuntime"; }
using Leadtools; using Leadtools.Codecs; using Leadtools.Controls; using Leadtools.Forms.Ocr; using Leadtools.Forms; using Leadtools.Forms.DocumentWriters; using Leadtools.ImageProcessing; private static async void OcrPageTypeExample() { OcrEngineType engineType = OcrEngineType.Advantage; IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(engineType, false); ocrEngine.Startup(null, null, String.Empty, Tools.OcrEnginePath); IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument(); IOcrPage ocrPage; StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(@"Assets\Ocr1.tif"); using (RasterImage image = await ocrDocument.RasterCodecsInstance.LoadAsync(LeadStreamFactory.Create(loadFile))) { // Convert the image to 24-bpp ColorResolutionCommand command = new ColorResolutionCommand(ColorResolutionCommandMode.InPlace, 24, RasterByteOrder.Bgr, RasterDitheringMethod.None, ColorResolutionCommandPaletteFlags.None, null); command.Run(image); // Show the original image properties Debug.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel); System.Diagnostics.Debug.Assert(image.BitsPerPixel == 24); // Add it to the OCR engine ocrPage = ocrDocument.Pages.AddPage(image, null); } // Show the current OCR page size and color depth using (RasterImage image = ocrPage.GetRasterImage(OcrPageType.Current)) { Debug.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 (RasterImage image = ocrPage.GetRasterImage(OcrPageType.Processing)) { Debug.WriteLine("Original size is {0} by {1} at {2} bits/pixel", image.ImageWidth, image.ImageHeight, image.BitsPerPixel); System.Diagnostics.Debug.Assert(image.BitsPerPixel == 1); } // Shutdown the engine ocrEngine.Shutdown(); }
System.Object
System.ValueType
System.Enum
Leadtools.Forms.Ocr.OcrPageType