Recognize Pages (C++ Builder 6.0)

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.

Add 2 buttons to your form and name them as follows:

 

Name

Caption

 

btnRecognize

Recognize

 

btnGetStatus

Get Status

3.

Handle the LEADRasterDocument1 OnRecognitionStatus event, and code the LEADRasterDocument1RecognitionStatus procedure as follows:

void __fastcall TForm1::LEADRasterDocument1RecognitionStatus(
      TObject *Sender, short iRecogPage, short iError) 
{
   ShowMessage ( "The page # " + IntToStr(iRecogPage) + "is finished its recognition\n" +
           "The recognition return code = " + IntToStr(iError) ); 
   //continue to recognize next page"
   LEADRasterDocument1->set_EnableStopRecognizeStatus ( False ); 
}

4.

Code the btnRecognize button's click procedure as follows:

void __fastcall TForm1::btnRecognizeClick(TObject *Sender) 
{
   int nRet; 

   LEADRasterDocument1->set_SpellLanguageID( LANGID_ENGLISH ); 
   LEADRasterDocument1->set_EnableSubSystem( True ); 
   LEADRasterDocument1->set_EnableCorrection ( True ); 

   LEADRasterDocument1->set_RecognitionDataFileName ( AnsiToOLESTR("c:\\testrdf.rdf") ); 

   nRet= LEADRasterDocument1->Recognize ( 0, 1 ); 
   if ( nRet == 0 ) 
      ShowMessage ( "The engine finished recognizing the specified pages successfully" ); 
   else
      ShowMessage ( "Error" + IntToStr(nRet) + "in recognized specified pages" ); 
}

5.

Code the btnGetStatus button's click procedure as follows:

void __fastcall TForm1::btnGetStatusClick(TObject *Sender) 
{
   int nRet; 

   nRet= LEADRasterDocument1->GetStatus ( ); 
   if ( nRet == 0 ) 
   {
      ShowMessage ( "Recognition Time = " + IntToStr(LEADRasterDocument1->RecognizeStatus->RecognizedTime) + "\n" +
            "Total Recognized Characters = " + IntToStr(LEADRasterDocument1->RecognizeStatus->RecognizedCharacterCount) + "\n" +
            "Total Recognized Words = " + IntToStr(LEADRasterDocument1->RecognizeStatus->RecognizedWordCount) + "\n" +
            "Total Rejected Characters = " + IntToStr(LEADRasterDocument1->RecognizeStatus->RejectCharacterCount) + "\n" +
            "Total Rejected Words = " + IntToStr(LEADRasterDocument1->RecognizeStatus->RejectWordCount) ); 
   }
}

6.

Run your program to test it.

7.

Save the project to use as a starting point for other tasks in this tutorial.