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

54
LINES

< > BotCompany Repo | #1015416 // Recognize test screen shots v2 with proper teaching [OK]

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

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

!7

static JNavigation nav;
static File dataDir;
static volatile bool stopRecognizing;

p-noconsole {
  autoRestart();
  nav = jnavigation();
  frameIcon(#1101244, showMaximizedFrame(nav));
  dataDir = javaxDataDir("Screen shots for text recognition");
  
  showButton("Stop recognizing other files", r { stopRecognizing = true; disableButton() });

  // Recognize existing & new  
  onNewFileInDirWithExtension(dataDir, ".png", voidfunc(File f) { recognizeFile(f, true) });
  for (final File f : sortFilesByDateDesc(listPNGFiles(dataDir)))
    if (!stopRecognizing) 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;
    
    Runnable reRecognize = r {
      print("Re-recognizing...");
      temp tempDisposeWindow(smallLoadingAnim());
      replaceCollection(lines, ocr_recognizeMultiLine_scored(img));
      is.repaint();
      print("Done");
    };
    final ReliableSingleThread rst = new ReliableSingleThread(reRecognize);
    is.specialPurposed = true;
    
    showImageWithRecognizedTexts(img, is, lines);
    showImageWithRecognizedTexts_makeTeachable2(img, is, lines,
      filledSimpleRecognizer_cached(), r { rst.trigger() });
      
    ret jtabs(
      "Picture", jscroll(is),
      "Raw", jtextarea(pnlStructToString(lines))
    );
  };
  
  addToNavPossiblyOnTop(onTop, nav, f.getName(), makeComponent);
}

Author comment

Began life as a copy of #1015276

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: #1015416
Snippet name: Recognize test screen shots v2 with proper teaching [OK]
Eternal ID of this version: #1015416/9
Text MD5: 43e7b5ab7427d9fdf01d729df3f24bc6
Transpilation MD5: 994b33d1a89f4d29649d786f000d7992
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-19 10:51:23
Source code size: 1767 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 449 / 1097
Version history: 8 change(s)
Referenced in: [show references]