Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1015309 // Recognize test screen shots v2 [dev.]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Transpiled version (11043L) is out of date.

!7

p-subst {
  autoRestart();
  JNavigation nav = jnavigation();
  frameIcon(#1101244, showMaximizedFrame(nav));
  File dataDir = javaxDataDir("Screen shots for text recognition");
  
  for (final File f : sortFilesByDateDesc(listPNGFiles(dataDir))) {
    final BufferedImage img = loadBufferedImage(f);
    print("Recognizing: " + f.getName() + " (" + bufferedImageSizeWithStar(img) + ")");
    long time = sysNow();
    final L<RecognizedText> lines = ocr_recognizeMultiLine_scored(img);
    print("  " + (sysNow()-time) + "  ms");
    nav.addPage(f.getName(), func -> JComponent {
      final new ImageSurface is;
      is.specialPurposed = true;
      showImageWithRecognizedTexts(img, is, lines);
      
      onImageSurfaceHighlightChange(is, voidfunc(Rect r) {
        RecognizedText rec = findByField(lines, +r);
        setToolTip(is, rec == null ? null : str(rec.text));
      });
      
      imageSurfacePopupMenuWhenHighlighted_top(is, voidfunc(JPopupMenu menu, final Rect r) {
        final RecognizedText rec = findByField(lines, +r);
        addPopupMenuItem(menu, "OK: " + rec.text!, r {
          appendToTextFile_uniq(changeExtension(f, ".expected"),
            struct(ll(rec.text!, rec.r)));
        });
        addSeparator(menu);
      });
      
      ret jtabs(
        "Picture", jscroll(is),
        "Raw", jtextarea(pnlStructToString(lines))
      );
    });
  }
}

Author comment

Began life as a copy of #1015276

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015309
Snippet name: Recognize test screen shots v2 [dev.]
Eternal ID of this version: #1015309/5
Text MD5: e06ab7478f3b85c790c1edbeec5a2f94
Author: stefan
Category: javax / ocr
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-12 18:12:48
Source code size: 1432 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 273 / 625
Version history: 4 change(s)
Referenced in: [show references]