Tesseract Command line yields different results from API

268 views
Skip to first unread message

Reinaldo Crespo

unread,
Nov 16, 2016, 5:16:17 PM11/16/16
to tesseract-ocr
Hello everyone;

Tesseract from command line yields decent results.  However, from API, the results are not as good.

I've written a few c wrapper functions in order to use Tesseract from harbour.

This code works fine but yields different and less accurate text when compared from command line output:

   handle := TessBaseAPICreate()       //Using Tesseract to OCR image
   IF TessBaseAPIInit3( handle, NIL, "eng" ) != 0 ; LOOP ; ENDIF    //abort if english traindata file can't be found locally.

    //line below is commented to avoid program from freezing when calling TessBaseAPIGetUTF8Text()
    //TessBaseAPISetPageSegMode( handle, 3 )   //this line causes program to freeze when calling GetUTF8Text() below

    img := pixRead( ALLTRIM( cPath )+cFile )

    TessBaseAPISetImage2( handle, img )

    IF TessBaseAPIRecognize( handle, Nil ) != 0  ; LOOP   ;ENDIF      //abort if Recognize fails

    cText := TessBaseAPIGetUTF8Text( handle )    //program will freeze here unless SetPageSegMode above is commented 


I'm guessing the reason output is different is do to PSM mode defaults to different values on command line use versus from API.   However, when I uncomment the line "TessBaseAPISetPageSegMode( handle, 3 )" to make sure PSM is same as command line default then the program freezes when executing TessBaseAPIGetUTF8Text( handle).

Can someone, please, help me understand what I might be doing wrong?

Thank you,



Reinaldo.

Quan Nguyen

unread,
Nov 18, 2016, 10:06:49 AM11/18/16
to tesseract-ocr
It seems that the command-line now uses TextRenderer API rather than GetUTF8Text method.

Reinaldo Crespo

unread,
Nov 24, 2016, 11:06:28 AM11/24/16
to tesseract-ocr
Nguyen;

Thank you for replying.   I can't find any API named "TextRenderer" or anything similar.  I'm working from c.  As I look at the exposed API functions on the lib I can't find any "TextRenderer".   Can you help?

Thank you,


Reinaldo.
Reply all
Reply to author
Forward
0 new messages