L_Doc2FindZones

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2FindZones(hDoc, nPageIndex)

L_HDOC2 hDoc;

/* handle to the OCR document */

L_INT nPageIndex;

/* page index */

Finds all zones in the specific page.

Parameter

Description

hDoc

Handle to the OCR document.

nPageIndex

Index of the page to search. This is a zero-based index.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The L_Doc2FindZones function is used for parsing the specified page (also called: auto-zoning), i.e. it analyzes the structure of the page layout and locates blocks for further processing.

The function performs the analysis within the page area of the image. It finds text or graphics blocks within the page area, builds an OCR zone list and then connects it to the specified page.

Zones found by this function are entered in a sequential list, called the OCR zone list, which is attached to the specified page. When this function is called, any previously inserted zones are deleted from this list.

To get the number of OCR zones list, use the L_Doc2GetZoneCount function.

To retrieve the number of OCR zones list and number of user zones, use the L_Doc2GetZoneCount function.

Zones can be deleted from this list using the L_Doc2RemoveZone function. You can get the zone parameters by calling the L_Doc2GetZone function. After modifying some zone attributes, use the L_Doc2UpdateZone function to apply the changes to the zone.

When working with zones from the OCR zone list, the following members cannot be updated:

This function finds the zone coordinates and the type of the zone.

New zones created by this function always take the value DOC2_ZONE_CHAR_FILTER_DEFAULT, meaning that the zone will take on the global filter setting (which is by default DOC2_ZONE_CHAR_FILTER_DEFAULT to have no filtering).

New zones located by this function always have the DOC2_FILL_DEFAULT and DOC2_RECOGMODULE_AUTO values in their FillMethod and RecogModule fields, respectively. The "meaning" of the DOC2_FILL_DEFAULT filling method can be specified with the L_Doc2SetFillMethod function. There is no corresponding function for specifying the default recognition module.

New zones created by this function always have empty strings in their ZONEDATA2.szSection member, which specifies the use of the default section of any enabled User dictionary.

The L_Doc2FindDefaultFillMethod function can be used when you don't know the type of page to be processed.

To set Auto Zone options, call the L_Doc2SetZoneOptions function.

To get Auto Zone options, call the L_Doc2GetZoneOptions function.

Required DLLs and Libraries

LTDOC2

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_Doc2AddZone, L_Doc2GetZoneCount, L_Doc2GetZone, L_Doc2UpdateZone, L_Doc2RemoveZone, L_Doc2ImportZones, L_Doc2ExportZones, L_Doc2SetZoneOptions, L_Doc2GetZoneOptions

Topics:

OCR Functions: Zones

 

Working with Zones

Example

L_LTDOC2TEX_API  L_INT Doc2FindZonesExample(L_HDOC2 hDoc,L_INT nPageIndex)
{
   L_INT nRet;
   AUTOZONEOPTS2 ZoneOpts;

   ZeroMemory(&ZoneOpts, sizeof(AUTOZONEOPTS2));
   nRet = L_Doc2GetZoneOptions (hDoc, &ZoneOpts, sizeof(AUTOZONEOPTS2));
   if(nRet != SUCCESS)
      return nRet;
   ZoneOpts.bEnableForceSingleColumn = TRUE;
   ZoneOpts.bDetectNonGridedTables = TRUE;
   nRet = L_Doc2SetZoneOptions (hDoc, &ZoneOpts);
   if(nRet != SUCCESS)
      return nRet;

   nRet = L_Doc2FindZones(hDoc, nPageIndex);
   if (nRet == SUCCESS)
      MessageBox(NULL, TEXT("The engine finds all available zones in the specified page."), TEXT("Notice!"), MB_OK);

   L_INT nOcrZoneCount=0;
   nRet = L_Doc2GetZoneCount(hDoc, nPageIndex, &nOcrZoneCount);
   if (nRet != SUCCESS)
      return nRet;

   L_TCHAR szBuffer[100];
   memset(szBuffer, 0, sizeof(szBuffer));
   wsprintf(szBuffer, TEXT("Total zones in the specified page = %d\n"), nOcrZoneCount);
   MessageBox(NULL, szBuffer, TEXT("Zone Count!"), MB_OK);
   return SUCCESS;
}