OcrZoneType Enumeration (original) (raw)

Syntax

C#

Objective-C

C++/CLI

Java

Python

[SerializableAttribute()] public enum OcrZoneType

typedef NS_ENUM(NSInteger, LTOcrZoneType) { LTOcrZoneTypeText = 0, LTOcrZoneTypeTable, LTOcrZoneTypeGraphic, LTOcrZoneTypeOmr, LTOcrZoneTypeMicr, LTOcrZoneTypeIcr, LTOcrZoneTypeMrz, LTOcrZoneTypeBarcode, LTOcrZoneTypeNone, LTOcrZoneTypeFieldData, LTOcrZoneTypeCmc7 };

[SerializableAttribute()] public enum class OcrZoneType

class OcrZoneType(Enum): Text = 0 Table = 1 Graphic = 2 Omr = 3 Micr = 4 Icr = 5 Mrz = 6 Barcode = 7 None = 8 FieldData = 9 Cmc7 = 10 OcrA = 11

Members

Value Member Description
0 Text Flowing text type zone.
1 Table Table type zone.
2 Graphic Zone containing graphics.
3 Omr OMR (Optical Markup Recognition) zone.
4 Micr MICR (Magnetic Ink Character Recognition) zone. Check processing. Currently, the engine does not auto-detect MICR zones. Instead, use MICRCodeDetectionCommand to detect the MICR zone area automatically, if needed, and add an OcrZone object with OcrZoneType.Micr to the page. After the zone with MICR data is recognized, call the ExtractMicrData method to parse the row data into an OcrMicrData object.
5 Icr ICR (Intelligent Character Recognition) zone. Handwritten text and numbers.
6 Mrz MRZ (Machine Readable Zone). Only applicable to passports and identity cards. Travel passports worldwide are MRPs (machine-readable passports). They are standardized by the ICAO Document 9303 (endorsed by the International Organization for Standardization and the International Electrotechnical Commission as ISO/IEC 7501-1) and have a special machine-readable zone (MRZ). MRZs are usually at the bottom of the identity page at the beginning of a passport. MRZ text uses capital letters and digits separated by one or more < characters (for example, P<<FIRSTNAME<<<<<LASTNAME). Currently, the engine does not auto-detect MRZ zones. Instead, call MRZCodeDetectionCommand to detect the MRZ zone area automatically, if needed, and add an OcrZone object with OcrZoneType.Mrz to the page. After a zone with MRZ data is recognized, call IOcrZoneCharacters to parse the row data.
7 Barcode Barcode zone. Currently, the engine does not auto-detect barcode zones. Instead, call the BarcodeReader to detect the barcode zone area(s) automatically, if needed, and add an OcrZone object with OcrZoneType.Barcode to the page. For future use by LEADTOOLS.
8 None No recognition zone.
9 FieldData Field data zone (for example, the name, address, and date fields in passports and identity cards). Field data uses capital letters, digits, and separators. Currently, the engine does not auto-detect field data zones. Set field data manually if a zone is known to contain field data. After a zone with field data is recognized, call IOcrZoneCharacters to parse the row data.
10 Cmc7 CMC7 zone filling method. ConnectCode MICR CMC7 font is based on the CMC-7 (ISO 1004) industry standard.
11 OcrA OCR zone

Example

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"; }