←Select platform

NativeOcrZoneType Enumeration

Summary
Native zone types.
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum NativeOcrZoneType   
public enum NativeOcrZoneType 
[SerializableAttribute()] 
public enum class NativeOcrZoneType   
class NativeOcrZoneType(Enum): 
   Text = 0 
   Table = 1 
   Graphic = 2 
   Column = 3 
   Header = 4 
   Footer = 5 
   Caption = 6 
   Title = 7 
   Other = 8 
   AutoGraphic = 9 
   VerticalText = 10 
   LeftRotatedText = 11 
   RightRotatedText = 12 
Members
ValueMemberDescription
0Text Flowing text type zone.
1Table Table type zone.
2Graphic Zone containing graphics (Not sure).
3Column Column type zone.
4Header Header type zone.
5Footer Footer type zone.
6Caption Caption type zone.
7Title Title type zone.
8Other Other zone type.
9AutoGraphic Zone containing graphics (sure).
10VerticalText Vertical characters. For Asian characters only.
11LeftRotatedText Left rotated text (90 degrees counter clockwise). For Latin, Greek and Cyrillic characters only.
12RightRotatedText Right rotated text (90 degrees clockwise). For Latin, Greek and Cyrillic characters only.
Remarks

Used with engine-specific zones. For more information, refer to IOcrZoneManager.GetNativeZone and IOcrZoneManager.SetNativeZone.

The NativeOcrZoneType is used to classify the zone into one of the three basic zone-categories: flowing text, table or graphics. For these, use NativeOcrZoneType.Text, NativeOcrZoneType.Table, and NativeOcrZoneType.Graphic respectively.

For flowing text, any of the following text types can appear instead of NativeOcrZoneType.Text: NativeOcrZoneType.Column, NativeOcrZoneType.Header, NativeOcrZoneType.Footer, NativeOcrZoneType.Caption, NativeOcrZoneType.Title, NativeOcrZoneType.VerticalText, NativeOcrZoneType.LeftRotatedText, NativeOcrZoneType.RightRotatedText or NativeOcrZoneType.Other.

One of these values is typically created by the page-layout decomposition (auto-zoning) process of the page (see IOcrPage.AutoZone), however they have the same meaning for the recognition algorithms: the zone contains flowing text.

The NativeOcrZoneType.Table type is for table-type zones. In this type of zone is specified, the OCR engine will try to reconstruct the original table text layout of the zone in the final output document.

For graphic zones use the NativeOcrZoneType.Graphic type. If NativeOcrZoneType.Graphic is specified, no recognition will be run on the zone and all other recognition related settings will be ignored. The related NativeOcrZoneType.AutoGraphic type can appear as the result of the page-layout decomposition (auto-zoning) process, and also signifies a graphic zone. The difference is, NativeOcrZoneType.Graphic is the type that you as the user set in the zone to denote a graphic zone that contain no text, NativeOcrZoneType.AutoGraphic is the type set by the engine during auto-zoning.

Each OCR engine supports different type of zones. To get the type of zones supported by the engine, use IOcrZoneManager.GetSupportedZoneTypes. Trying to set a zone type that is not supported by the engine will cause an error.

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 OcrAutoZoneExample() 
{ 
   // Create an image with some text in it 
   RasterImage image = new RasterImage(RasterMemoryFlags.Conventional, 320, 200, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0); 
   Rectangle imageRect = new Rectangle(0, 0, image.ImageWidth, image.ImageHeight); 
 
   IntPtr hdc = RasterImagePainter.CreateLeadDC(image); 
   using (Graphics g = Graphics.FromHdc(hdc)) 
   { 
      g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 
      g.FillRectangle(Brushes.White, imageRect); 
 
      using (Font f = new Font("Arial", 20, FontStyle.Regular)) 
         g.DrawString("Normal line", f, Brushes.Black, 0, 0); 
 
      using (Font f = new Font("Courier New", 20, FontStyle.Regular)) 
         g.DrawString("Monospaced line", f, Brushes.Black, 0, 80); 
   } 
 
   RasterImagePainter.DeleteLeadDC(hdc); 
 
   string zonesFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyZones.xml"); 
 
   // 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 page 
      using (IOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose)) 
      { 
         // Show the zones, there should be no zones yet 
         ShowZones("Right after the page was created", ocrPage); 
 
         // Perform default AutoZoning on the page 
         ocrPage.AutoZone(null); 
 
         // Show the zones, there should be two zones, one for each line 
         ShowZones("AutoZone with default parameters", ocrPage); 
 
         // Update the first zone manually 
         OcrZone ocrZone = ocrPage.Zones[0]; 
         ocrZone.ZoneType = OcrZoneType.Text; 
         ocrPage.Zones[0] = ocrZone; 
 
         // Show the zones 
         ShowZones("After updating the type of the first zone", ocrPage); 
 
         // Save the zones to a file and then clear them 
         ocrPage.SaveZones(zonesFileName); 
         ocrPage.Zones.Clear(); 
 
         // Show the zones, there should be no zones since we just cleared them 
         ShowZones("After calling save and clear", ocrPage); 
 
         // Re-load the zones 
         ocrPage.LoadZones(zonesFileName); 
         ShowZones("After re-loading the zones", ocrPage); 
      } 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
} 
 
private void ShowZones(string message, IOcrPage ocrPage) 
{ 
   Console.WriteLine("Zones after {0}:", message); 
   foreach (OcrZone ocrZone in ocrPage.Zones) 
   { 
      int index = ocrPage.Zones.IndexOf(ocrZone); 
      Console.WriteLine("Zone index: {0}", index); 
      Console.WriteLine("  Id                  {0}", ocrZone.Id); 
      Console.WriteLine("  Bounds              {0}", ocrZone.Bounds); 
      Console.WriteLine("  ZoneType            {0}", ocrZone.ZoneType); 
      Console.WriteLine("  CharacterFilters:   {0}", ocrZone.CharacterFilters); 
      Console.WriteLine("----------------------------------"); 
   } 
 
   Console.WriteLine("Hit enter to continue"); 
   //Console.ReadLine(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.3.3
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.