!752 concept GrabbedImage { long lastScreenshotTime; Rect lastRect; BWImage image; S md5; int count; BWImage visualizedSplit; new L rects; new L characters; new L characterMD5s; S recognition; } concept RecogInfo { new L 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 data; for (GrabbedImage gi : sortByFieldDesc(in.list(GrabbedImage), "lastScreenshotTime")) { if (gi.visualizedSplit == null) { L 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 rects = gi.rects; if (group) { rects = ocr_groupRects(rects, s); s = ocr_unmerge(s); } L 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"); } }