Recognize Pages Using LEADTOOLS OCR Module - OmniPage Engine

To add code to an existing project in order to recognize pages:

  1. Start with the program you created in Working with Zones.

  2. Define the following global IDs in Ezfunc.h in the OCR_Ltdoc2 directory:

    #define IDM_RECOGNIZE               205 
    #define IDM_GET_STATUS              206 

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

    MAIN_MENU   MENU 
    BEGIN 
       ... 
       ... 
       MENUITEM "Recognize Page"        IDM_RECOGNIZE 
       MENUITEM "Engine Status"         IDM_GET_STATUS 
    END 

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

    case IDM_RECOGNIZE: 
    { 
       RECOGNIZEOPTS2 RecogOpts; 
       memset(&RecogOpts, 0, sizeof(RECOGNIZEOPTS2)); 
       RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
       RecogOpts.nPageIndexStart = 0; 
       RecogOpts.nPagesCount = 1; 
       RecogOpts.SpellLangId = DOC2_LANG_ID_ENGLISH; 
       RecogOpts.bEnableSubSystem = TRUE; 
       RecogOpts.bEnableCorrection = TRUE; 
       nRet = L_Doc2Recognize(hDoc, &RecogOpts, RecognizeStatusCB, NULL); 
       if (nRet == SUCCESS) 
          MessageBox(NULL, TEXT("The engine finished recognizing the specified pages successfully."), TEXT("Notice"), MB_OK); 
       else 
       { 
          wsprintf (achBuff, TEXT("Error %d in recognized pages"), nRet); 
          MessageBox (NULL, achBuff, TEXT("Error"), MB_OK); 
       } 
    } 
    break; 
     
    case IDM_GET_STATUS: 
    { 
       STATUS2 Status; 
       memset(&Status, 0, sizeof(STATUS2)); 
       nRet = L_Doc2GetStatus(hDoc, &Status, sizeof(STATUS2)); 
       if (nRet == SUCCESS) 
       { 
          wsprintf(achBuff, TEXT("Recognition Time = %d\nTotal Recognized Characters = %d\nTotal Recognized Words = %d\nTotal Rejected Characters = %d\n "), 
          Status.lRecogTime, 
          Status.nRecogChrCount, 
          Status.nRecogWordCount, 
          Status.nRejectChrCount); 
          MessageBox(NULL, achBuff, TEXT("Status..."), MB_OK); 
       } 
    } 
    break; 

  5. Add at the end of the code the following function in EZFUNC.CPP in OCR_Ltdoc2 directory.

    L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, L_INT nError, L_VOID * pUserData) 
    { 
       UNREFERENCED_PARAMETER(pUserData); 
       L_TCHAR szBuffer[1024]; 
       wsprintf(szBuffer, TEXT("Page # %d has finished recognition.\nThe recognition return code = %d\n"), nRecogPage, nError); 
       MessageBox(NULL, szBuffer, TEXT("Recognition Status"), MB_OK); 
       return SUCCESS; // continue to recognize next page 
    } 

  6. Also, add the following statement before the MainWndProc function

    L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, L_INT nError, L_VOID * pUserData); 

  7. Build SimpleLoad.exe.

  8. Run SimpleLoad.exe.

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.