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).

1  
!7
2  
3  
static JNavigation nav;
4  
static File dataDir;
5  
static volatile bool stopRecognizing;
6  
7  
p-noconsole {
8  
  autoRestart();
9  
  nav = jnavigation();
10  
  frameIcon(#1101244, showMaximizedFrame(nav));
11  
  dataDir = javaxDataDir("Screen shots for text recognition");
12  
  
13  
  showButton("Stop recognizing other files", r { stopRecognizing = true; disableButton() });
14  
15  
  // Recognize existing & new  
16  
  onNewFileInDirWithExtension(dataDir, ".png", voidfunc(File f) { recognizeFile(f, true) });
17  
  for (final File f : sortFilesByDateDesc(listPNGFiles(dataDir)))
18  
    if (!stopRecognizing) recognizeFile(f, false);
19  
    
20  
21  
}
22  
23  
svoid recognizeFile(final File f, bool onTop) {
24  
  final BufferedImage img = loadBufferedImage(f);
25  
  print("Recognizing: " + f.getName() + " (" + bufferedImageSizeWithStar(img) + ")");
26  
  long time = sysNow();
27  
  final L<RecognizedText> lines = ocr_recognizeMultiLine_scored(img);
28  
  print("  " + (sysNow()-time) + "  ms");
29  
  
30  
  F0<JComponent> makeComponent = func -> JComponent {
31  
    final new ImageSurface is;
32  
    
33  
    Runnable reRecognize = r {
34  
      print("Re-recognizing...");
35  
      temp tempDisposeWindow(smallLoadingAnim());
36  
      replaceCollection(lines, ocr_recognizeMultiLine_scored(img));
37  
      is.repaint();
38  
      print("Done");
39  
    };
40  
    final ReliableSingleThread rst = new ReliableSingleThread(reRecognize);
41  
    is.specialPurposed = true;
42  
    
43  
    showImageWithRecognizedTexts(img, is, lines);
44  
    showImageWithRecognizedTexts_makeTeachable2(img, is, lines,
45  
      filledSimpleRecognizer_cached(), r { rst.trigger() });
46  
      
47  
    ret jtabs(
48  
      "Picture", jscroll(is),
49  
      "Raw", jtextarea(pnlStructToString(lines))
50  
    );
51  
  };
52  
  
53  
  addToNavPossiblyOnTop(onTop, nav, f.getName(), makeComponent);
54  
}

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: 451 / 1100
Version history: 8 change(s)
Referenced in: [show references]