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

62
LINES

< > BotCompany Repo | #1005879 // Learn to read v3 (saving results, dev.)

JavaX source code - run with: x30.jar

!752

!include #1005875 // Distinguisher

please include function img_upperWidthToLowerWidth.
please include function img_averageWidthDividedByHeight.
please include function img_centralPixelSet.
please include function img_leftishness.

concepts.

concept Task {
  S characters; // the 2 characters to distinguish from each other
  S font; // Font name or snippet ID
  new BitSet fontSizes;
  new RefL<VirtFunc> solutions;
}

concept VirtFunc {
  S javaCode;
}

/*
concept Discriminator {}

Discriminator > FunctionValue {
  S name; // including the "img_"
  float threshold;
  S comparator; // lt, !lt, gt, !gt, eq, ne
}
*/

sS font = "#1004569";
static float size = 10f;

static BWImage render(S text) {
  ret autoCroppedBWImage(renderText(font, size, text));
}

p {
  //showBWImage(render("01"));

  new Distinguisher d;
  for (final S f : splitAtSpace("upperWidthToLowerWidth averageWidthDividedByHeight centralPixelSet leftishness"))
    d.addFunction(f, func(BWImage img) { call(mc(), "img_" + f, img) });
  print("Got " + l(d.functions) + " functions.");
  
  int lastQuality = -1;
  for (size = 60f; size >= 10f; size--) {
    print("Rendering size " + (int) size);
    d.analyze(ll(render("0"), render("1")));
    int quality = d.quality();
    if (quality != lastQuality) {
      print("Distinguisher quality now: " + quality);
      if (quality == 0)
        break;
      lastQuality = quality;
    }
  }
  
  d.printStuff();
}

Author comment

Began life as a copy of #1005878

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: #1005879
Snippet name: Learn to read v3 (saving results, dev.)
Eternal ID of this version: #1005879/1
Text MD5: b2135762b3a1d285d3d10feacb2856fa
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-11 17:36:45
Source code size: 1500 bytes / 62 lines
Pitched / IR pitched: No / No
Views / Downloads: 472 / 493
Referenced in: