LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Accessing and Modifying NativeOcrZones
#1
Posted
:
Friday, January 25, 2019 4:22:53 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 163
Was thanked: 9 time(s) in 9 post(s)
The LEADTOOLS SDK uses OcrZones to define regions of interest. Behind the scenes, they are converted into NativeOcrZone structures specific to the engine being used. It is not possible to directly add a NativeOcrZone. However, generated NativeOcrZones can be extracted and modified.
Here's a code snippet that shows how to access a NativeOcrZone, modify one of its properties, and re-insert it back into the collection:
Code:
using (IOcrEngine engine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false))
{
engine.Startup(null, null, null, null);
IOcrPage page = engine.CreatePage(inputImage, OcrImageSharingMode.None);
// insert a new zone
page.Zones.Add(new OcrZone() { Bounds = new LeadRect(0, 0, 100, 100)});
// extract the NativeOcrZone at index 0 (the OcrZone we just added)
NativeOcrZone nativeZone = engine.ZoneManager.GetNativeZone(page, 0);
// change one of its properties
nativeZone.RecognitionModule = NativeOcrZoneRecognitionModule.DotMatrix;
// insert the zone back into its original index
engine.ZoneManager.SetNativeZone(page, 0, nativeZone);
page.Recognize(null);
engine.Shutdown();
}
Here's our documentation links for the GetNativeZone() and SetNativeZone() methods.
https://www.leadtools.com/help/leadtools/v20/dh/fo/iocrzonemanager-getnativezone.htmlhttps://www.leadtools.com/help/leadtools/v20/dh/fo/iocrzonemanager-setnativezone.htmlDo note that for a vast majority of OCR operations using the OcrZone structure is sufficient and accessing the NativeOcrZones is not necessary.
However, this demonstrates a way to accommodate edge cases where it's necessary to access lower-level properties that aren't immediately exposed, such as the NativeOcrZoneRecognitionModule as detailed. For more information, see our overview on Recognition Modules:
https://www.leadtools.com/help/leadtools/v20/dh/to/an-overview-of-ocr-recognition-modules-for-the-leadtools-ocr-module-omnipage-engine.htmlNick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Accessing and Modifying NativeOcrZones
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.