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

46
LINES

< > BotCompany Repo | #1005878 // Learn to read v2 (using Distinguisher)

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

Libraryless. Click here for Pure Java version (8375L/59K/227K).

1  
!7
2  
3  
!include #1005875 // Distinguisher
4  
5  
please include function img_upperWidthToLowerWidth.
6  
please include function img_averageWidthDividedByHeight.
7  
please include function img_centralPixelSet.
8  
please include function img_leftishness.
9  
10  
sS font = "#1004569";
11  
static float size = 10f;
12  
13  
static BWImage render(S text) {
14  
  ret autoCroppedBWImage(renderText(font, size, text));
15  
}
16  
17  
p-type {
18  
  showBWImage(render("01"));
19  
20  
  new Distinguisher d;
21  
  for (final S f : splitAtSpace("upperWidthToLowerWidth averageWidthDividedByHeight centralPixelSet leftishness"))
22  
    d.addFunction(f, func(BWImage img) { call(mc(), "img_" + f, img) });
23  
  print("Got " + l(d.functions) + " functions.");
24  
  
25  
  int lastQuality = -1, sizes = 0;
26  
  for (size = 60f; size >= 10f; size--) {
27  
    ++sizes;
28  
    print("Rendering size " + (int) size);
29  
    d.analyze(ll(render("0"), render("1")));
30  
    int quality = d.quality();
31  
    if (quality != lastQuality) {
32  
      print("Distinguisher quality now: " + quality);
33  
      if (quality == 0)
34  
        break;
35  
      lastQuality = quality;
36  
    }
37  
  }
38  
  
39  
  print();
40  
  d.printStuff();
41  
  
42  
  printAsciiHeading("Summary");
43  
  print("Analyzed '0' and '1' in font " + font + " in " + sizes + " sizes.");
44  
  print("=> " + (d.good() ? "Discriminator good (quality=" + d.quality() + ")" : "Discriminator failed";
45  
  
46  
}

Author comment

Began life as a copy of #1005852

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005878
Snippet name: Learn to read v2 (using Distinguisher)
Eternal ID of this version: #1005878/2
Text MD5: b3f26edb476a5628322d9f1a69bbfa81
Transpilation MD5: baa81dbafd23e3586aa18ebd7e5cc347
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-11 22:14:16
Source code size: 1352 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 586 / 663
Version history: 1 change(s)
Referenced in: [show references]