please include function showImageWithSelections. static float showImageWithSelections_darkening = 0.75f; static ImageSurface showImageWithRecognizedTexts(BufferedImage img, ImageSurface _is, final L<RecognizedText> rects) { final ImageSurface is = showImage(img, _is); is.specialPurposed = true; final new Var<Rect> highlighted; showImageWithSelections_highlighted = highlighted; is.overlay = voidfunc(Graphics2D g) { fillRect(g, 0, 0, is.getWidth(), is.getHeight(), colorWithAlpha(Color.black, showImageWithSelections_darkening)); antiAliasOn(g); temp tempGraphicsTransform(g); g.scale(is.zoomX, is.zoomY); Font font = g.getFont().deriveFont(12); g.setFont(font); FontMetrics fm = g.getFontMetrics(); for (RecognizedText r : cloneList(rects)) { is.drawSelectionRect(g, r.r.getRectangle(), Color.blue, blendColor(Color.black, Color.white, /*ocr_minScoreAdjust*/(r.score())), 1, 1); S text = r.text!; if (nempty(text) && neq(text, ocr_unknownCharacterPlaceholder())) { Pt p = centerTextInRect(fm, r.text!, r.r); // Pt p = pt(r.r.x+2, r.r.y+2); drawTextWithOutline(g, r.text!, p.x, p.y, 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))/*)*/; }); imageSurfacePopupMenuOnSelection_top(is, voidfunc(JPopupMenu menu, final Rect selection) { addMenuItem(menu, "Export selected texts", r { showText("Selected recognized texts", lines(allToStruct(recognizedTextsFullyContainedIn(rects, selection)))) }); }); ret repaint(is); }
Began life as a copy of #1005839
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015302 |
Snippet name: | showImageWithRecognizedTexts |
Eternal ID of this version: | #1015302/30 |
Text MD5: | 8f5aa7abab77e22dbf32277e27389b05 |
Author: | stefan |
Category: | javax / imaging / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-07 20:05:40 |
Source code size: | 1879 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 444 / 477 |
Version history: | 29 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |