←Select platform

NativeOcrZoneFillMethod Enumeration

Summary
Possible content types of the zones
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum NativeOcrZoneFillMethod 
public enum NativeOcrZoneFillMethod 
[SerializableAttribute()] 
public enum class NativeOcrZoneFillMethod   
class NativeOcrZoneFillMethod(Enum): 
   Default = 0 
   OmniFont = 1 
   Omr = 2 
   Icr = 3 
   DraftDotMatrix9 = 4 
   DraftDotMatrix24 = 5 
   OcrA = 6 
   OcrB = 7 
   Micr = 8 
   DotDigit = 9 
   DashDigit = 10 
   NoRecognition = 11 
   Asian = 12 
   FieldData = 13 
   Cmc7 = 14 
Members
ValueMemberDescription
0Default Default zone filling method. The IOcrPage.AutoZone(OcrProgressCallback callback) method will set all the fill method of the zones found to this value. You can set the zone filling method to another type by using IOcrPage.AutoZone(OcrZoneParser zoneParser, NativeOcrZoneFillMethod fillMethod, OcrProgressCallback callback) with fillMethod set the zone type desired.
1OmniFont Omnifont zone filling method. It denotes a machine printed text with any typeface which is not too stylized.
2Omr Optical mark zone filling method. It denotes a possible marking within the zone.
3Icr Hand-printed zone filling method.
4DraftDotMatrix9 9-pin draft dot-matrix zone filling method. It denotes a 9-pin draft dot-matrix printout.
5DraftDotMatrix24 24-pin draft dot-matrix zone filling method. It denotes a 24-pin draft dot-matrix printout.
6OcrA OCR-A zone filling method.
7OcrB OCR-B zone filling method.
8Micr Magnetic ink character filling method. Mostly used in bank checks.
9DotDigit Dot-digit zone filling method.
10DashDigit Dash-digit zone filling method.
11NoRecognition No recognition will be attempted.
12Asian The zone contains Asian characters.
13FieldData The zone contains field data.
14Cmc7 CMC7 zone filling method.
Remarks

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

A fill method must have been assigned to all zones in their NativeOcrZone.FillMethod properties before processing.

Not all fill methods are available to all engines. To determine which fill methods are available use IOcrZoneManager.GetSupportedNativeFillMethods. Trying to set a fill method not available to the engine will cause an error.

Each zone needs to be associated with a NativeOcrZoneRecognitionModule and NativeOcrZoneFillMethod. This is needed because some recognition modules support more than one fill method, and some fill methods are accepted by more than one recognition module.

It is important to ensure that the recognition module/fill method pair is suitable.

Note that the auto-zoning IOcrPage.AutoZone will create the zones with the value NativeOcrZoneFillMethod.Default in their NativeOcrZone.FillMethod properties.

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:\LEADTOOLS22\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Ocr Assembly

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