Advanced Zone Locator — External Recognition Engine
QAID # 17767 Published * INTERNAL ONLY *
Please do NOT provide the article number (QAID) and/or URL of this Knowledgebase article or its contents to external customers, as it is NOT Published and/or * INTERNAL ONLY *.
Question / Problem:
Advanced Zone Locator — External Recognition Engine
Answer / Solution:
Use Case
In Japan, it was desired to use an external recognition engine for reading zones.
This article describes how this can be done, whilst at the same time making use of all of the KTM Advanced Zone Locator features such as:
- Background Removal
- Registration
- Anchoring
- Dynamic Zone Adjustment
- Image Clean
QAID 17338 — External OCR Engine shows how an external engine can be used for full page recognition.
Solution
The Advanced Zone Locator (AZL) is used to define the areas on the Document that we want to read, optionally using all of the features available with the AZL to prepare the zone image for the recognition engine. The zone image is then read with an OMR profile, as the time needed to perform OMR is negligible. This read result will be over written in script once the AZL has been executed.
The AZL can temporarily, during extraction, save its processed zonal image snippets to memory. It is this information that the external recognition engine uses in script.
Per default the AZL does not do this, so we have to switch this on in script, before the AZL is executed. This is done in the Document_BeforeExtract
event:
Private Sub Document_BeforeExtract(ByVal pXDoc As CASCADELib.CscXDocument) Dim C As CscClass Dim oLocDef As CscLocatorDef Dim oLocMeth As ICscExtractionMethod Dim oAZL As CscAdvZoneLocator Set C = Project.ClassByName("Base") Set oLocDef = C.Locators.ItemByName("AZL") Set oLocMeth = oLocDef.LocatorMethod Set oAZL = oLocMeth '# Per default oAZL.SaveXDocImages = False. Setting oAZL.SaveXDocImages = True will cause the AZL image snippets to be saved to memory whilst processing the xDoc '# These AZL image snippets can be used by the external recognition engine in the locatore SL_AZL, which is executed after the AZL. '# The AZL can perform the registration, background removal, anchoring and image clean optionally oAZL.SaveXDocImages = True End Sub
An example of zones that we want to read:
The AZL stores the zone images temporarily in memory during extraction.
These zone images are used in script by the external recognition engine.
Private Sub SL_AZL_LocateAlternatives(ByVal pXDoc As CASCADELib.CscXDocument, _ ByVal pLocator As CASCADELib.CscXDocField) Dim Rep As CscXDocRepresentation Dim Alt As CscXDocFieldAlternative Dim SF As CscXDocSubField Dim i As Integer If pXDoc.Representations.ItemByName("AdvZoneLoc").Images.Count > 0 Then Set Rep = pXDoc.Representations.ItemByName("AdvZoneLoc") Set Alt = pXDoc.Locators.ItemByName("AZL").Alternatives(0) For i = 0 To Rep.Images.Count - 1 '# Save the image snippet to disk, ' if you want to see exactly what image snippet the external engine gets to read '# Comment out the next line of code at production time Rep.Images(i).Image.Save("C:\Temp\Christian\SF_" + Rep.Images(i).Name + ".tif") '# Get the AZL sub-field that is to be read by the external recognition engine Set SF = Alt.SubFields.ItemByName("SF_" & Rep.Images(i).Name) Select Case SF.Name Case "SF_Name" '# Place your code here to read this zone with the appropriate ' profile of the external engine SF.Text = "Christian" SF.ExtractionConfident = True SF.Confidence = 1 Case "SF_FamilyName" '# Place your code here to read this zone with the appropriate ' profile of the external engine SF.Text = "Booker" '# Set the sub-field text to the read result '# Set the sub-field extraction confident = True/False '# Set the sub-field confidence to the read confidence Case "SF_Address" '# Place your code here to read this zone with the appropriate ' profile of the external engine SF.Text = "Wetzingerstrasse 19, Freiburg" '# Set the sub-field text to the read result '# Set the sub-field extraction confident = True/False '# Set the sub-field confidence to the read confidence Case "SF_TelephoneNumber" '# Place your code here to read this zone with the appropriate ' profile of the external engine SF.Text = "0761 45269 100" '# Set the sub-field text to the read result '# Set the sub-field extraction confident = True/False '# Set the sub-field confidence to the read confidence End Select Next End If End Sub
Download
Click the link below to download a KTM demo project:
Advanced Zone Locator - External Recognition Engine (Created with KTM 5.0).
Applies to:
Product | Version | Category |
---|---|---|
AXPRO | 5.5 | Project Builder |