Recognize Pages
Take the following steps to add code to the existing project that will let you recognize pages:
1. |
Start with the program you created in Working with Zones. | |
2. |
In Resource View tab, open the EZFUNC resources, and open MAIN_MENU1 menu to add the a new menu item as follows: | |
|
a. |
Select an empty rectangle in the menu, and right click on that box and select Properties. |
|
b. |
Set the ID to IDM_RECOGNIZE and the Caption to Recognize Page. Make sure Checked has been selected. Press Enter. |
|
c. |
Another rectangle appears on the menu. Right click on that box and select Properties. |
|
d. |
Set the ID to IDM_GET_STATUS and the Caption to Engine Status. Make sure Checked has been selected. Press Enter. |
3. |
In the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND: |
case IDM_RECOGNIZE:
{
RECOGNIZEOPTS RecogOpts;
memset(&RecogOpts, 0, sizeof(RECOGNIZEOPTS));
RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS);
RecogOpts.nPageIndexStart = 0;
RecogOpts.nPagesCount = 1;
RecogOpts.SpellLangId = LANG_ID_ENGLISH;
RecogOpts.bEnableSubSystem = TRUE;
RecogOpts.bEnableCorrection = TRUE;
RecogOpts.pszFileName = TEXT("c:\\testrdf.rdf");
nRet = L_DocRecognize(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:
{
STATUS Status;
memset(&Status, 0, sizeof(STATUS));
nRet = L_DocGetStatus(hDoc, &Status, sizeof(STATUS));
if (nRet == SUCCESS)
{
wsprintf(achBuff, TEXT("Recognition Time = %d\nTotal Recognized Characters = %d\nTotal Recognized Words = %d\nTotal Rejected Characters = %d\nTotal Rejected Words = %d\n"),
Status.lRecogTime,
Status.nRecogChrCount,
Status.nRecogWordCount,
Status.nRejectChrCount,
Status.nRejectWordCount);
MessageBox(NULL, achBuff, TEXT("Status..."), MB_OK);
}
}
break;
4. |
Add the following function in EZFUNC.C in EZOCRDOC directory. |
L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, L_INT nError, L_VOID L_FAR * 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
}
5. |
Also, add the following statement before the MainWndProc function |
L_INT EXT_CALLBACK RecognizeStatusCB(L_INT nRecogPage, L_INT nError, L_VOID L_FAR * pUserData);
6. |
Build Ezfunc32.exe. |
7. |
Run Ezfunc32.exe. |