Character confidence

1,268 views
Skip to first unread message

hiran.suvrat

unread,
Jun 2, 2012, 4:32:44 AM6/2/12
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

zdenko podobny

unread,
Jun 2, 2012, 4:45:37 AM6/2/12
to tesser...@googlegroups.com
have a look at issue 714[1]. Reporter proposed also fix (you will need to change tessseract code)



--
You received this message because you are subscribed to the Google
Groups "tesseract-ocr" group.
To post to this group, send email to tesser...@googlegroups.com
To unsubscribe from this group, send email to
tesseract-oc...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en



hiran.suvrat

unread,
Jun 2, 2012, 6:38:53 AM6/2/12
to tesseract-ocr
Guys got it working...

u need to do save_blob_choices instead of save_best_choices.
To get symbols follow the link
http://code.google.com/p/tesseract-ocr/issues/detail?id=714<http://code.google.com/p/tesseract-ocr/issues/detail?id=714#c1>
Thanks a lot Zdenko



On Jun 2, 1:45 pm, zdenko podobny <zde...@gmail.com> wrote:
> have a look at issue 714[1]. Reporter proposed also fix (you will need to
> change tessseract code)
>
> [1]http://code.google.com/p/tesseract-ocr/issues/detail?id=714<http://code.google.com/p/tesseract-ocr/issues/detail?id=714#c1>
>
> --
> Zdenko
Reply all
Reply to author
Forward
0 new messages