hiran.suvrat
unread,Jun 2, 2012, 4:32:44 AM6/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to tesseract-ocr
Hi,
I went through lot of pages to find how to generate character level
confidence but with now success. I have also include
SetVariable("save_best_choices", "T") but it still des not work. Can
somebody please debug the code. Thanks a lot.
Code:
#include "allheaders.h"
#include "baseapi.h"
#include "strngs.h"
#include "tesseractmain.h"
#include "tprintf.h"
int main(int argc, char **argv) {
const char *lang="eng";
const PIX *pixs;
if ((pixs = pixRead(argv[1])) == NULL) {
printf("Unsupported image type.\n");
exit(3);
}
tesseract::TessBaseAPI api;
api.SetVariable("save_best_choices", "T");
api.SetImage(pixs);
int rc = api.Init(argv[0], lang);
api.Recognize(NULL);
tesseract::ResultIterator* ri = api.GetIterator();
tesseract::ChoiceIterator* ci;
if(ri != 0)
{
do
{
const char* symbol = ri->GetUTF8Text(tesseract::RIL_SYMBOL);
// printf("======================");
if(symbol != 0)
{
float conf = ri->Confidence(tesseract::RIL_SYMBOL);
printf("\nnext symbol: %s, conf: %f", symbol, conf,
"\n");
const tesseract::ResultIterator itr = *ri;
ci = new tesseract::ChoiceIterator(itr);
do
{
printf("----");
const char* choice = ci->GetUTF8Text();
printf("\t\t%s conf: %f", choice, ci->Confidence());
}
while(ci->Next());
delete ci;
}
delete[] symbol;
} while((ri->Next(tesseract::RIL_SYMBOL)));
}
return 0;
}
Output:
next symbol: c, conf: 85.844711---- (null) conf: 0.000000
next symbol: o, conf: 85.844711---- (null) conf: 0.000000
next symbol: m, conf: 85.844711---- (null) conf: 0.000000
next symbol: Q, conf: 0.000000---- (null) conf: 0.000000
Does anybody see a problem in it??
Thanks in advance