private List < Word > getRecognizedWords ( int pageIteratorLevel ) { List < Word > words = new ArrayList < Word > ( ) ; try { TessResultIterator ri = api . TessBaseAPIGetIterator ( handle ) ; TessPageIterator pi = api . TessResultIteratorGetPageIterator ( ri ) ; api . TessPageIteratorBegin ( pi ) ; do { Pointer ptr = api . TessResultIteratorGetUTF8Text ( ri , pageIteratorLevel ) ; String text = ptr . getString ( 0 ) ; api . TessDeleteText ( ptr ) ; float confidence = api . TessResultIteratorConfidence ( ri , pageIteratorLevel ) ; IntBuffer leftB = IntBuffer . allocate ( 1 ) ; IntBuffer topB = IntBuffer . allocate ( 1 ) ; IntBuffer rightB = IntBuffer . allocate ( 1 ) ; IntBuffer bottomB = IntBuffer . allocate ( 1 ) ; api . TessPageIteratorBoundingBox ( pi , pageIteratorLevel , leftB , topB , rightB , bottomB ) ; int left = leftB . get ( ) ; int top = topB . get ( ) ; int right = rightB . get ( ) ; int bottom = bottomB . get ( ) ; Word word = new Word ( text , confidence , new Rectangle ( left , top , right - left , bottom - top ) ) ; words . add ( word ) ; } while ( api . TessPageIteratorNext ( pi , pageIteratorLevel ) == TRUE ) ; } catch ( Exception e ) { logger . warn ( e . getMessage ( ) , e ) ; } return words ; }
Gets result words at specified page iterator level from recognized pages .