←Select platform

IsRecognized Property

Gets a value that indicates whether this page has been recognized at least once.
public bool IsRecognized { get; } 
@property (nonatomic, assign, readonly) BOOL isRecognized 
public boolean isRecognized() 
property bool IsRecognized { 
   bool get(); 
IsRecognized # get  (IOcrPage) 

Property Value

true if this IOcrPage has been recognized at least once, otherwise it is false.


You can recognize a page with the Recognize method. The OCR recognition data is collected and stored internally in the page. You can also recognize all or some of the pages in the engine with the IOcrPageCollection.Recognize method of the collection that owns this page (IOcrDocument.Pages).

Once a page is recognized, you can call the GetRecognizedCharacters and SetRecognizedCharacters methods to examine and manipulate the recognition data.

You can call the Unrecognize method to clear the recognition data stored inside the page. Calling this method after the page is recognized will have the same effect as having a page that never been recognized. The value of IsRecognized will be set back to false after calling Unrecognize.

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 OcrPageExample() 
   string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf"); 
   // 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 document 
      using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
         // Add this image to the document 
         IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, null); 
         // Auto-recognize the zones in the page 
         // Show its information 
         Console.WriteLine("Size: {0} by {1} pixels", ocrPage.Width, ocrPage.Height); 
         Console.WriteLine("Resolution: {0} by {1} dots/inch", ocrPage.DpiX, ocrPage.DpiX); 
         Console.WriteLine("Bits/Pixel: {0}, Bytes/Line: {1}", ocrPage.BitsPerPixel, ocrPage.BytesPerLine); 
         byte[] palette = ocrPage.GetPalette(); 
         int paletteEntries; 
         if (palette != null) 
            paletteEntries = palette.Length / 3; 
            paletteEntries = 0; 
         Console.WriteLine("Number of entries in the palette: {0}", paletteEntries); 
         Console.WriteLine("Original format of this page: {0}", ocrPage.OriginalFormat); 
         Console.WriteLine("Has this page been recognized? : {0}", ocrPage.IsRecognized); 
         // Recognize it and save it as PDF 
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null); 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
private void ShowZonesInfo(IOcrPage ocrPage) 
   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); 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 

Target Platforms

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