/** A wrapper for {@link #setImage(int, int, ByteBuffer, Rectangle, int)}. */
 private void setImage(RenderedImage image, Rectangle rect) throws IOException {
   setImage(
       image.getWidth(),
       image.getHeight(),
       ImageIOHelper.getImageByteBuffer(image),
       rect,
       image.getColorModel().getPixelSize());
 }
 /**
  * Performs OCR operation.
  *
  * @param bi a buffered image
  * @param rect the bounding rectangle defines the region of the image to be recognized. A
  *     rectangle of zero dimension or <code>null</code> indicates the whole image.
  * @return the recognized text
  * @throws TesseractException
  */
 public String doOCR(BufferedImage bi, Rectangle rect) throws TesseractException {
   try {
     return doOCR(ImageIOHelper.getIIOImageList(bi), rect);
   } catch (Exception e) {
     logger.log(Level.SEVERE, e.getMessage(), e);
     throw new TesseractException(e);
   }
 }