1 | !752 |
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 | concepts. |
11 | |
12 | concept Task { |
13 | S characters; // the 2 characters to distinguish from each other |
14 | S font; // Font name or snippet ID |
15 | new BitSet fontSizes; |
16 | new RefL<VirtFunc> solutions; |
17 | } |
18 | |
19 | concept VirtFunc { |
20 | S javaCode; |
21 | } |
22 | |
23 | /* |
24 | concept Discriminator {} |
25 | |
26 | Discriminator > FunctionValue { |
27 | S name; // including the "img_" |
28 | float threshold; |
29 | S comparator; // lt, !lt, gt, !gt, eq, ne |
30 | } |
31 | */ |
32 | |
33 | sS font = "#1004569"; |
34 | static float size = 10f; |
35 | |
36 | static BWImage render(S text) { |
37 | ret autoCroppedBWImage(renderText(font, size, text)); |
38 | } |
39 | |
40 | p { |
41 | //showBWImage(render("01")); |
42 | |
43 | new Distinguisher d; |
44 | for (final S f : splitAtSpace("upperWidthToLowerWidth averageWidthDividedByHeight centralPixelSet leftishness")) |
45 | d.addFunction(f, func(BWImage img) { call(mc(), "img_" + f, img) }); |
46 | print("Got " + l(d.functions) + " functions."); |
47 | |
48 | int lastQuality = -1; |
49 | for (size = 60f; size >= 10f; size--) { |
50 | print("Rendering size " + (int) size); |
51 | d.analyze(ll(render("0"), render("1"))); |
52 | int quality = d.quality(); |
53 | if (quality != lastQuality) { |
54 | print("Distinguisher quality now: " + quality); |
55 | if (quality == 0) |
56 | break; |
57 | lastQuality = quality; |
58 | } |
59 | } |
60 | |
61 | d.printStuff(); |
62 | } |
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: | 473 / 495 |
Referenced in: | [show references] |