Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS OCR C DLL Help

Working with Zones Using OCR Plus

Show in webframe

To add code to an existing project that will let you recognize pages:

1.

Start with the program you created in Working with Pages.

2.

Define the following global IDs in Ezfunc.h in the OCR_Ltdoc directory:

#define IDM_FIND_ZONES              201
#define IDM_ZONES_COUNT             202
#define IDM_ADD_VERIFICATION_ZONE   203
 

3.

Edit EZFUNC.RC file in the OCR_Ltdoc directory and add the following lines:

 

MAIN_MENU   MENU
BEGIN
   ... 
   ... 
   MENUITEM "Find Zones"            IDM_FIND_ZONES
   MENUITEM "Zone Count"            IDM_ZONES_COUNT
   MENUITEM "Add Verification Zone" IDM_ADD_VERIFICATION_ZONE
END

 

4.

Define the following global variables in Ezfunc.H in the OCR_Ltdoc directory:

L_INT nZoneCount;

 

5.

In Ezfunc.cpp in the MainWndProc procedure, add the following code to the switch ("switch(LOWORD(wParam))")statement for WM_COMMAND:

      case IDM_FIND_ZONES:
         {
            AUTOZONEOPTS ZoneOpts;
            memset(&ZoneOpts, 0, sizeof(AUTOZONEOPTS));

            ZoneOpts.uStructSize = sizeof(AUTOZONEOPTS);
            ZoneOpts.bEnableForceSingleColumn = TRUE;
            ZoneOpts.bVisibleGridLines = TRUE;

            L_DocSetZoneOptions(hDoc, &ZoneOpts);
            nRet = L_DocFindZones(hDoc, 0, NULL);
            if (nRet == SUCCESS)
               MessageBox(NULL, TEXT("The automatic zone method found all available zones in the specified pages successfully."), TEXT("Notice!"), MB_OK);
            else
            {
               wsprintf (achBuff, TEXT("Error %d in finding available zones in the specified page."), nRet);
               MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
            }
            InvalidateRect (hWnd, NULL, FALSE);        

         }

         break;
      case IDM_ZONES_COUNT:
         {
            nRet = L_DocGetZoneCount(hDoc, 0, &nZoneCount);
            if (nRet == SUCCESS)
            {
               wsprintf(achBuff, TEXT("Total Zones count = %d\n\nRefer to OCR Utility Demo to see an example of the zones being identified (Zone->Find Zones, Zone->Zones Count...). \nUse same document as in this tutorial"), nZoneCount); 
           
               MessageBox(NULL, achBuff, TEXT("Zones Count"), MB_OK);
            }
         }
         break;
      case IDM_ADD_VERIFICATION_ZONE:
         {
            ZONEDATA Zone;
            L_INT i;
            for(i=0; i<nZoneCount; i++)
            {
               memset(&Zone, 0, sizeof(ZONEDATA));
               nRet = L_DocGetZone(hDoc, 0, i, &Zone, sizeof(ZONEDATA));
               if (nRet == SUCCESS)
               {
                  if ((Zone.uFlags & ZONE_CHK_CHECKCBF_PROHIBIT) == ZONE_CHK_CHECKCBF_PROHIBIT)
                     Zone.uFlags &= ~ZONE_CHK_CHECKCBF_PROHIBIT;

                  Zone.pfnCallback = VerificationCB;
                  nRet = L_DocUpdateZone(hDoc, 0, i, &Zone);
                  if (nRet != SUCCESS)
                  {
                     wsprintf (achBuff, TEXT("Error %d in updating zone # %d"), nRet, i);
                     MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
                  }
               }
            }
         }
         break;

 

6.

Add the following function at the end of the file in EZFUNC.CPP in the OCR_Ltdoc directory.

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR * pszWord, VERIFYCODE * pVerify, L_VOID * pUserData)
{
   UNREFERENCED_PARAMETER(nZoneIndex); 
   UNREFERENCED_PARAMETER(pszWord); 
   UNREFERENCED_PARAMETER(pUserData); 

   *pVerify = VERIFY_ACCEPT; 
   return SUCCESS;
}

7.

Also, add the following statement before the MainWndProc function.

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR * pszWord, VERIFYCODE * pVerify, L_VOID * pUserData); 

10.

Build SimpleLoad.exe.

11.

Run SimpleLoad.exe.

Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.