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

37
LINES

< > BotCompany Repo | #1015276 // Recognize test screen shots v1 [OK]

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (11402L/82K).

!7

static JNavigation nav;
static File dataDir;

p-noconsole {
  autoRestart();
  nav = jnavigation();
  frameIcon(#1101244, showMaximizedFrame(nav));
  dataDir = javaxDataDir("Screen shots for text recognition");

  // Recognize existing & new  
  onNewFileInDirWithExtension(dataDir, ".png", voidfunc(File f) { recognizeFile(f, true) });
  for (final File f : sortFilesByDateDesc(listPNGFiles(dataDir))) recognizeFile(f, false);
}

svoid recognizeFile(final File f, bool onTop) {
  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");
  F0<JComponent> makeComponent = func -> JComponent {
    final new ImageSurface is;
    is.specialPurposed = true;
    showImageWithRecognizedTexts(img, is, lines);
    
    showImageWithRecognizedTexts_makeTeachable(is, lines, changeExtension(f, ".expected"));
    
    ret jtabs(
      "Picture", jscroll(is),
      "Raw", jtextarea(pnlStructToString(lines))
    );
  };
  
  addToNavPossiblyOnTop(onTop, nav, f.getName(), makeComponent);
}

Author comment

Began life as a copy of #1015275

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015276
Snippet name: Recognize test screen shots v1 [OK]
Eternal ID of this version: #1015276/30
Text MD5: 830372cb69c41bf0bc139ec7e7da1ff6
Transpilation MD5: da7a341f2e01552f35cb1803cf2cac0d
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-13 18:48:51
Source code size: 1234 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 487 / 1303
Version history: 29 change(s)
Referenced in: [show references]