←Select platform

OcrZoneCell Class

Summary
Contains information of a cell in a zone of type OcrZoneType.Table
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public class OcrZoneCell 
@interface LTOcrZoneCell : NSObject<NSCopying> 
public class OcrZoneCell 
[SerializableAttribute()] 
public ref class OcrZoneCell  
class OcrZoneCell: 
Remarks

This class contains the information for one cell:

Member Description
OcrZoneCell.Bounds

The bounding rectangle of the cell in pixels

OcrZoneCell.CellType

The type of the cell.

OcrZoneCell.BackgroundColor

The background color of the cell.

OcrZoneCell.LeftBorderColor, OcrZoneCell.LeftBorderStyle, OcrZoneCell.LeftBorderWidth

The properties of the left border of the cell: Its color, style (none, solid, dashed, etc.) and its width.

OcrZoneCell.TopBorderColor, OcrZoneCell.TopBorderStyle, OcrZoneCell.TopBorderWidth

The properties of the top border of the cell: Its color, style (none, solid, dashed, etc.) and its width.

OcrZoneCell.RightBorderColor, OcrZoneCell.RightBorderStyle, OcrZoneCell.RightBorderWidth

The properties of the right border of the cell: Its color, style (none, solid, dashed, etc.) and its width.

OcrZoneCell.BottomBorderColor, OcrZoneCell.BottomBorderStyle, OcrZoneCell.BottomBorderWidth

The properties of the bottom border of the cell: Its color, style (none, solid, dashed, etc.) and its width.

You can use table cells in one of two ways:

To manipulate a cell properties other than its bound (OcrZoneCell.Bounds), get the array of detected cells through IOcrZoneCollection.GetZoneCells, change the cell background color, style or any border color, style or with. When you are done, re-set the array using IOcrZoneCollection.SetZoneCells.

It is not recommended that you manually remove or add cells to the array, the engine is very sensitive to zone boundaries and any non-accurate information will cause an error. Instead, use the various methods of IOcrTableZoneManager to manipulate the cell location and size.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Ocr; 
using Leadtools.Drawing; 
 
private static void IOcrTableZoneManageExample(IOcrEngine ocrEngine, string documentFileName) 
{ 
   // Create a document and add the page to it 
   using (IOcrPage ocrPage = ocrEngine.CreatePage(ocrEngine.RasterCodecsInstance.Load(documentFileName, 1), OcrImageSharingMode.AutoDispose)) 
   { 
      // The coordinate for the table has been previously determined: 
      LeadRect tableBounds = new LeadRect(266, 554, 404, 647); 
 
      // Add a table zone with these bounds 
      OcrZone zone = new OcrZone(); 
      zone.ZoneType = OcrZoneType.Table; 
      zone.Bounds = tableBounds; 
      ocrPage.Zones.Add(zone); 
 
      if (ocrPage.TableZoneManager != null) 
      { 
         // Detect the cells inside this table 
         IOcrTableZoneManager ocrTableZoneManager = ocrPage.TableZoneManager; 
         ocrTableZoneManager.AutoDetectCells(0); 
      } 
 
      // Show the cells for this zone (if any) 
      zone = ocrPage.Zones[0]; 
 
      Console.WriteLine("Detected values:"); 
      ShowCells(ocrPage, zone); 
 
      // Change the style of the first cell to have no borders 
      OcrZoneCell[] cells = ocrPage.Zones.GetZoneCells(zone); 
      if (cells != null && cells.Length > 0) 
      { 
         OcrZoneCell cell = cells[0]; 
         cell.LeftBorderStyle = OcrCellBorderLineStyle.None; 
         cell.TopBorderStyle = OcrCellBorderLineStyle.None; 
         cell.RightBorderStyle = OcrCellBorderLineStyle.None; 
         cell.BottomBorderStyle = OcrCellBorderLineStyle.None; 
         cells[0] = cell; 
      } 
 
      ocrPage.Zones.SetZoneCells(zone, cells); 
 
      Console.WriteLine("Updated values:"); 
      ShowCells(ocrPage, zone); 
   } 
} 
 
private static void ShowCells(IOcrPage ocrPage, OcrZone zone) 
{ 
   OcrZoneCell[] cells = ocrPage.Zones.GetZoneCells(zone); 
   if (cells != null) 
   { 
      Console.WriteLine("Table contains {0} zones", cells.Length); 
 
      for (int i = 0; i < cells.Length; i++) 
      { 
         Console.WriteLine("  Cell {0}:", i); 
 
         OcrZoneCell cell = cells[i]; 
         Console.WriteLine("    Type: {0}", cell.CellType); 
         Console.WriteLine("    Bounds: {0}", cell.Bounds); 
         Console.WriteLine("    Background color: {0}", cell.BackgroundColor); 
         Console.WriteLine("    Left border color: {0}", cell.LeftBorderColor); 
         Console.WriteLine("    Left border width: {0}", cell.LeftBorderWidth); 
         Console.WriteLine("    Left border style: {0}", cell.LeftBorderStyle); 
         Console.WriteLine("    Top border color: {0}", cell.TopBorderColor); 
         Console.WriteLine("    Top border width: {0}", cell.TopBorderWidth); 
         Console.WriteLine("    Top border style: {0}", cell.TopBorderStyle); 
         Console.WriteLine("    Right border color: {0}", cell.RightBorderColor); 
         Console.WriteLine("    Right border width: {0}", cell.RightBorderWidth); 
         Console.WriteLine("    Right border style: {0}", cell.RightBorderStyle); 
         Console.WriteLine("    Bottom border color: {0}", cell.BottomBorderColor); 
         Console.WriteLine("    Bottom border width: {0}", cell.BottomBorderWidth); 
         Console.WriteLine("    Bottom border style: {0}", cell.BottomBorderStyle); 
      } 
   } 
} 
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.