@Override
    public List<Rectangle> getSegmentedRegions(BufferedImage bi, int pageIteratorLevel) throws TesseractException {
        init();
        setTessVariables();

        try {
            List<Rectangle> list = new ArrayList<Rectangle>();
            setImage(bi, null);

            Boxa boxes = TessBaseAPIGetComponentImages(handle, pageIteratorLevel, TRUE, null, null);
            int boxCount = Leptonica1.boxaGetCount(boxes);
            for (int i = 0; i < boxCount; i++) {
                Box box = Leptonica1.boxaGetBox(boxes, i, L_CLONE);
                if (box == null) {
                    continue;
                }
                list.add(new Rectangle(box.x, box.y, box.w, box.h));
                PointerByReference pRef = new PointerByReference();
                pRef.setValue(box.getPointer());
                Leptonica1.boxDestroy(pRef);
            }

            PointerByReference pRef = new PointerByReference();
            pRef.setValue(boxes.getPointer());
            Leptonica1.boxaDestroy(pRef);

            return list;
        } catch (IOException ioe) {
            // skip the problematic image
            logger.warn(ioe.getMessage(), ioe);
            throw new TesseractException(ioe);
        } finally {
            dispose();
        }
    }
@ Override public List < Rectangle > getSegmentedRegions ( BufferedImage bi , int pageIteratorLevel ) throws TesseractException { init ( ) ; setTessVariables ( ) ; try { List < Rectangle > list = new ArrayList < Rectangle > ( ) ; setImage ( bi , null ) ; Boxa boxes = TessBaseAPIGetComponentImages ( handle , pageIteratorLevel , TRUE , null , null ) ; int boxCount = Leptonica1 . boxaGetCount ( boxes ) ; for ( int i = 0 ; i < boxCount ; i ++ ) { Box box = Leptonica1 . boxaGetBox ( boxes , i , L_CLONE ) ; if ( box == null ) { continue ; } list . add ( new Rectangle ( box . x , box . y , box . w , box . h ) ) ; PointerByReference pRef = new PointerByReference ( ) ; pRef . setValue ( box . getPointer ( ) ) ; Leptonica1 . boxDestroy ( pRef ) ; } PointerByReference pRef = new PointerByReference ( ) ; pRef . setValue ( boxes . getPointer ( ) ) ; Leptonica1 . boxaDestroy ( pRef ) ; return list ; } catch ( IOException ioe ) { logger . warn ( ioe . getMessage ( ) , ioe ) ; throw new TesseractException ( ioe ) ; } finally { dispose ( ) ; } }
Gets segmented regions at specified page iterator level.

@param bi input image
@param pageIteratorLevel TessPageIteratorLevel enum
@return list of <code>Rectangle</code>
@throws TesseractException