Libraryless. Click here for Pure Java version (9737L/69K/231K).
!7 static int sleepTimeWhenNotFound = 5000; static JFrame frame; static SingleComponentPanel scp; static ImageSurface imageSurface; static FindURLBox1 finder; static BoxShot shot; static TimeRange timeRange; concept BoxShot { S imageMD5; byte[] png; new RefL<TimeRange> timeRanges; } concept Evaluation { new Ref<BoxShot> shot; S comment; } Evaluation > WrongResult {} Evaluation > GoodResult {} p { conceptsAndBot(60*1000); awt { finder = new FindURLBox1; JComponent feedback = jRightAlignedLine( jlabel("Is this the right box?"), jbutton("Yes", "yes"), jbutton("No", "no")); scp = new SingleComponentPanel(jcenteredLabel("-")); frame = showFrame("Find URL Box", centerAndSouth(scp, feedback)); frameIcon(frame, #1005541); frameInnerSize(frame, 500, 100); moveToBottomRightCorner(frame); frame.setAlwaysOnTop(true); awtCalcRegularly(frame, 200, 0, r { final bool b = finder.go(); awt { if (b) { RGBImage img = finder.bestImage(); S since = ""; if (shot != null && timeRange != null) since = ", since " + (now()-timeRange.from)/1000 + "s, " + nth(l(shot.timeRanges)) + " appearance)"; S text = "URL box found in " + finder.recogTime + " ms (" + img.w() + "*" + img.h() + " px" + since + ")"; if (imageSurface == null) { imageSurface = new ImageSurface(img); scp.setComponent(jSection(text, new JScrollPane(imageSurface))); } else { imageSurface.setImage(img); setSectionTitle(imageSurface, text); } S imageMD5 = md5OfRGBImage(img); shot = uniq(BoxShot, +imageMD5); if (shot.png == null) shot.png = rgbImageToPNG(img); if (shot.timeRanges.contains(timeRange)) timeRange.addNow(); else shot.timeRanges.add(timeRange = new TimeRange(now())); shot.change(); } else { shot = null; timeRange = null; if (imageSurface != null) { imageSurface = null; scp.setComponent(jcenteredLabel("URL box not found (" + finder.recogTime + " ms)")); } } } if (!b) sleep(sleepTimeWhenNotFound); }); } } svoid yes { print("yes"); feedback(new GoodResult); } svoid no { feedback(new WrongResult); } svoid feedback(Evaluation ev) { cset(ev, +shot); infoMessage("Thank you, " + (ev << WrongResult ? "negative" : "positive") + " feedback recorded. (id=" + ev.id + ")"); mainConcepts.save(); }
Began life as a copy of #1006232
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006242 |
Snippet name: | Record browser's URL box with feedback [works] |
Eternal ID of this version: | #1006242/1 |
Text MD5: | e2decbe68cf9cd2db2691ae8632ef0d3 |
Transpilation MD5: | f4829c6a92a52283101c2229f22e8163 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-25 21:31:34 |
Source code size: | 2685 bytes / 93 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 571 / 658 |
Referenced in: | [show references] |