public int Id { get; set; }
An integer value specifying the zone ID.
The zone ID is managed by the engine and so the application is not allowed to change its value.
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 itRasterImage 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 engineusing (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)){// Start the engine using default parametersocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);// Create an OCR pageusing (IOcrPage ocrPage = ocrEngine.CreatePage(image, OcrImageSharingMode.AutoDispose)){// Show the zones, there should be no zones yetShowZones("Right after the page was created", ocrPage);// Perform default AutoZoning on the pageocrPage.AutoZone(null);// Show the zones, there should be two zones, one for each lineShowZones("AutoZone with default parameters", ocrPage);// Update the first zone manuallyOcrZone ocrZone = ocrPage.Zones[0];ocrZone.ZoneType = OcrZoneType.Text;ocrPage.Zones[0] = ocrZone;// Show the zonesShowZones("After updating the type of the first zone", ocrPage);// Save the zones to a file and then clear themocrPage.SaveZones(zonesFileName);ocrPage.Zones.Clear();// Show the zones, there should be no zones since we just cleared themShowZones("After calling save and clear", ocrPage);// Re-load the zonesocrPage.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 startedocrEngine.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";}