Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, June 7, 2017 3:48:03 PM(UTC)
Nick Villalobos

Groups: Registered
Posts: 119

Was thanked: 4 time(s) in 4 post(s)

There are multiple Ocr Zone Types that can be found when the LEADTOOLS OCR engine calls AutoZone to detect all the zones on a document. Sometimes the zoning may detect more zones than you would like to recognize.

Below you will find code that will demonstrate how to remove a graphic zone from the collection of zone types that have been found as well as Save the zones found, print out the bounds of the zones (x,y), recognize the document and save the text output as a text file.


// Create an instance of the engine 
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
   // Start the engine using default parameters 
   ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");

   // Create an OCR document 
   using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument())

      RasterImage image = ocrEngine.RasterCodecsInstance.Load(input, 0, CodecsLoadByteOrder.Rgb, 1, -1);
      // Add this image to the document 
      IOcrPage ocrPage = ocrDocument.Pages.AddPage(image, null);

      // Perform default AutoZoning on the page 

      foreach (OcrZone zone in ocrPage.Zones)
         if (zone.ZoneType == OcrZoneType.Graphic)

      // Save the zones
      ocrPage.SaveZones(@"SAVE LOCATION.ozf");

      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);

      //Recognize Page
      ocrDocument.Save(output, DocumentFormat.Text, null);

   // Shutdown the engine 
   // Note: calling Dispose will also automatically shutdown the engine if it has been started 

Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.070 seconds.