TessBaseAPISetPageSegMode API

44 views
Skip to first unread message

Reinaldo Crespo

unread,
Nov 18, 2016, 4:03:39 PM11/18/16
to tesseract-ocr
Tesseract.exe from command line defaults Page Segmentation Mode to 3 while from API it defaults to 6.  PSM of 3 yields much better results for the type of documents I'm processing but changing to PSM 3 causes API function TessBaseAPIRecognize to freeze program execution.

Is anyone changing PSM to 3 or 1 from API while successfully executing API Recognize later down the road?

Here is what my code looks like:

   handle := TessBaseAPICreate() 

   IF TessBaseAPIInit3( handle, NIL, "eng" ) == 0     //abort if english traindata file can't be found

            //change PSM to 3 =Fully automatic Page Seg but no OSD.
            TessBaseAPISetPageSegMode( handle, 3 ) 

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

            TessBaseAPISetImage2( handle, img )

            //program execution freezes right when calling next line
            //but only when PageSegMode is set to 3.  If I comment line above 
            //where PageSegMode is set to 3 then program execution flows 
            //without freezing on the next line.
            IF TessBaseAPIRecognize( handle, Nil ) <> 0  ; LOOP   ;ENDIF

            cText := TessBaseAPIGetUTF8Text( handle )
....


Please help, thank you.
Reply all
Reply to author
Forward
0 new messages