Uses 762K of libraries. Click here for Pure Java version (1411L/10K/33K).
1 | !752 |
2 | |
3 | lib 1003721 // lookup |
4 | lib 1003724 // commons io |
5 | lib 1003727 // commons lang |
6 | |
7 | import com.github.axet.lookup.*; |
8 | import com.github.axet.lookup.common.ImageBinaryGrey; |
9 | import org.apache.commons.io.FilenameUtils; |
10 | |
11 | static void loadFontsDirectory(OCR ocr, File dir) { |
12 | for (File f : listFiles(dir)) |
13 | loadFont(ocr, f); |
14 | } |
15 | |
16 | static void loadFont(OCR ocr, File path) ctex { |
17 | for (File f : listFiles(path)) { |
18 | InputStream is = new FileInputStream(f); |
19 | String symbol = FilenameUtils.getBaseName(f.getName()); |
20 | |
21 | try { |
22 | symbol = URLDecoder.decode(symbol, "UTF-8"); |
23 | } catch (UnsupportedEncodingException ee) { |
24 | throw new RuntimeException(ee); |
25 | } |
26 | |
27 | String name = path.getName(); |
28 | ocr.loadFontSymbol(name, symbol, is); |
29 | } |
30 | } |
31 | |
32 | p { |
33 | unzipSnippet("#1003720", programDir()); |
34 | |
35 | File dir = getProgramFile("lookup-examples"); |
36 | |
37 | OCR l = new OCR(0.70f); |
38 | |
39 | // will load all font |
40 | // familys (here is only font_1 family in this library) |
41 | loadFontsDirectory(l, new File(dir, "fonts")); |
42 | |
43 | // example how to load only one family |
44 | //l.loadFont(OCRTest.class, new File(dir, "fonts/font_1")); |
45 | |
46 | String str = ""; |
47 | |
48 | // recognize using all familys set |
49 | str = l.recognize(loadBufferedImage(new File(dir, "test3.png"))); |
50 | print(str); |
51 | |
52 | // recognize using only one family set |
53 | str = l.recognize(loadBufferedImage(new File(dir, "test3.png")), "font_1"); |
54 | print(str); |
55 | |
56 | // recognize using only one family set and rectangle |
57 | ImageBinaryGrey i = new ImageBinaryGrey(loadBufferedImage(new File(dir, "full.png"))); |
58 | str = l.recognize(i, 1285, 654, 1343, 677, l.getSymbols("font_1")); |
59 | print(str); |
60 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date |
---|---|---|---|
1267 | stefan | https://github.com/axet/lookup/ | 2016-07-26 15:28:13 |
1266 | stefan | Works!! | 2016-07-26 15:27:27 |
Snippet ID: | #1003722 |
Snippet name: | Test "Lookup" (On-Screen OCR) - WORKS |
Eternal ID of this version: | #1003722/1 |
Text MD5: | 747a455f6de970417a485857921e7e90 |
Transpilation MD5: | 91faadb97fb1ef1c4b971bf9ccb03c1a |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-17 00:49:13 |
Source code size: | 1681 bytes / 60 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 757 / 922 |
Referenced in: | [show references] |