OCR on a Multipage TIFF Image File (C++)

You are here:
< All Topics

This function process several images stored in a TIFF file. The results are stored in a text file.

void myOutputHandler(int infotype,int param); 
FILE *file; // file handler for result file 

int ProcessFile(const char *tifffile, const char *resultfile) 
{
SETOFIMG *set; 
IMG *img; 
int i; 
// load TIFF file 
set=LoadMultipleImg(tifffile); 
// check for error 
if (!set) 
return -1; 
// Open result file 
file=fopen(resultfile,"w"); 
// Initialize  engine 
SetLanguage(ENGLISH,"."); 
SetOutputMode(OM_TEXT); 
OCRSetOutputHandler(myOutputHandler); 
for(i=0;i<GetNbImages(set);i++) 
{
// get an image 
img=GetImage(set,i); 
// process it 
CR(img,0);
} 
// free the set 
FreeMultipleImg(set); 
// close result file 
fclose(file);
}

This function uses a OCR output handler that is defined now:

void myOutputHandler(int infotype,int param) 
{
int i; 
switch(infotype) 
{
case OT_TEXT:
fprintf(file,"%c",(char) param); 
break;
case OT_ENDL:
fprintf(file,"\\n"); 
break;
case OT_ENDZ:
fprintf(file,"\\n\\n");
}
}
Previous Introduction to SimpleOCR SDK
Next Scanning Documents (C++)
Table of Contents
Contact Us for FREE Consultation on Your OCR Project
Go to Top