please include function showImageWithSelections. static ImageSurface showImageWithRecognizedTexts(BufferedImage img, ImageSurface _is, final L rects) { final ImageSurface is = showImage(img, _is); final new Var highlighted; showImageWithSelections_highlighted = highlighted; is.overlay = voidfunc(Graphics2D g) { for (RecognizedText r : rects) { is.drawSelectionRect(g, r.r.getRectangle(), Color.blue, blendColor(Color.black, Color.white, r.score())); g.setFont(g.getFont().deriveFont(11+random()*4)); drawTextWithOutline(g, r.text!, r.x+2, r.y+2, Color.white, Color.black); } if (highlighted.has()) fillRect(g, scaleRect(highlighted!, is.getZoomX(), is.getZoomY()), new Color(0, 0, 0, 0x30)); // semi-transparent black }; imageSurfaceOnMouseMove(is, voidfunc(Pt p) { repaintIf(is, setVarIfNeq(highlighted, smallestRectContaining(collect(rects, 'r), p))); }); ret repaint(is); }