Libraryless. Click here for Pure Java version (10123L/72K/249K).
!752 concept GrabbedImage { long lastScreenshotTime; Rect lastRect; BWImage image; S md5; int count; BWImage visualizedSplit; new L<Rect> rects; new L<BWImage> characters; new L<S> characterMD5s; S recognition; } concept RecogInfo { new L<S> lines; } static SimpleRecognizer sr; static Concepts in; static JTable table; p { in = new Concepts("#1005951").load(); conceptsAndBot(); sr = new SimpleRecognizer; sr.load(joinLines(uniq(RecogInfo).lines)); update(); } svoid update { try { if (table != null) { frameIcon(table, "#1005541"); setFrameTitle(table, "Calculating - Recognitions"); } new L<L> data; for (GrabbedImage gi : sortByFieldDesc(in.list(GrabbedImage), "lastScreenshotTime")) { if (gi.visualizedSplit == null) { L<Rect> rects = horizontalAutoSplit2ThenAutoCrop(gi.image); cset(gi, visualizedSplit := new BWImage(mergeImagePartsHorizontally(gi.image.toRGB(), rects))); for (Rect r : rects) { BWImage cImg = gi.image.clip(r); gi.rects.add(r); gi.characters.add(cImg); gi.characterMD5s.add(md5OfBWImage(cImg)); } } S rec = sr.recognizeCheat(gi.image); if (rec != null) gi.recognition = "! " + rec; else gi.recognition = sr.recognize(gi.image); data.add(ll(gi.md5, gi.image.getBufferedImage(), gi.recognition, gi.visualizedSplit.getBufferedImage(), join(" ", gi.characterMD5s))); } bool first = table == null; table = showTableWithImages("Recognitions", splitAtSlash("MD5/Image/Recognition/Split/Character MD5s"), data, table); if (!first) ret; awt { table.setRowHeight(25); tablePopupMenu(table, voidfunc(JPopupMenu menu, final int row) { addMenuItem(menu, "Teach...", r { S md5 = cast getTableCell(table, row, 0); final GrabbedImage gi = findConcept(in, GrabbedImage, +md5); final new JTextField tf; final JCheckBox grouped = jCheckBox("grouped", true); final JButton btnSubmit = jbutton("Submit", r { S s = trim(tf.getText()); bool group = isChecked(grouped); L<Rect> rects = gi.rects; if (group) { rects = ocr_groupRects(rects, s); s = ocr_unmerge(s); } L<S> characterMD5s = md5OfBWImageParts(gi.image, rects); S line = "The images " + quote(join(" ", characterMD5s)) + " are the " + (group ? "grouped " : "") + "characters " + quote(s) + "."; print(">> " + line); RecogInfo ri = uniq(RecogInfo); if (setAdd(ri.lines, line)) { sr.load(line); ri.change(); } disposeFrame(tf); }); onUpdateAndNow(ll(tf, grouped), r { btnSubmit.setEnabled(ocr_charCountDropSpaces(trim(tf.getText()), isChecked(grouped)) == l(gi.characters)); }); showFormTitled("Teach", "Image:" , new ImageSurface(gi.image.getBufferedImage()), "Split:" , new ImageSurface(gi.visualizedSplit.getBufferedImage()), "Meaning:", tf, "", grouped, "", btnSubmit); }); addMenuItem(menu, "Mark on screen", r-thread { Rect r; pointArrowsToArea(r = parseRect(getTableLine(table, row).get(3))); print("Marking: " + r); }); }); gcAndPrintMemoryInfo(); awtCalcOnConceptChanges(table, 1000, 1000, func update, false); } } finally { frameIcon(table, null); setFrameTitle(table, "Recognitions"); } }
Began life as a copy of #1005971
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006104 |
Snippet name: | Show & recognize |
Eternal ID of this version: | #1006104/1 |
Text MD5: | 3c040049ab45bfb67b803e3765ae2221 |
Transpilation MD5: | 1e2ca71b40b3cbe27099c3bff6a8bf48 |
Author: | stefan |
Category: | javax / gui / ocr |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-22 23:35:51 |
Source code size: | 3787 bytes / 116 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 630 / 1685 |
Referenced in: | #1006164 - Test safeLoading concepts #1006187 - Show & recognize v2 (as class) #1006191 - Find images for character MD5s #1006275 - Get RecogInfo from Show & Recognize #1006297 - Delete GrabbedImage's from #1006104 #1015230 - getLearnedCharacters2 - OLD #3000425 - Recognition info from sawdedvomwva |