!7 concept Screenshot { new Ref<PNGFile> file; Image332 preview; } concept Grab { new Ref<Screenshot> screenshot; Pt point; new MultiSet<Rect> sizes; } p-substance-thread { db(); awt { showFrame(jtabs( "Shoot" := makeConceptTable(Screenshot), "Mark" := makeConceptTable(Screenshot), "Find" := makeConceptTable(Grab) )); } } svoid grab { trackOneClick(voidfunc(final Point p) { thread { sleep(500); // allow screen behind red dot to be repainted Grab grab = cnew(Grab, screenshot := new PNGFile(shootScreenBufferedImage()), point := new Pt(p) ); infoBox("Grabbed! " + grab.id); } }); } svoid find { float ppt = 0.1f; // per pixel tolerance RGBImage imgB = rgbShootScreen(); int w = imgB.w(), h = imgB.h(); for (Grab grab) { print ("Searching " + grab.id + "..."); RGBImage imgA = new RGBImage(grab.screenshot->getImage()); Pt p = grab.point; int col = imgA.getInt(p.x, p.y); new MultiSet<Rect> matches; for y to h: for x to w: if (rgbDiff(col, imgB.getInt(x, y)) <= ppt) { Rect r1 = new Rect(p.x, p.y, 1, 1); Rect r2 = new Rect(x, y, 1, 1); Rect r = translateRect(rgbExpandMatch(imgA, imgB, r1, r2, ppt), -p.x, -p.y); matches.add(r); } L<Rect> matchesList = sortByCalculatedFieldDesc(keys(matches), f rectPixels); Rect r = first(matchesList); if (r != null) print("Largest match: " + rectPixels(r) + " pixels. " + n(matchesList, "matches") + ": " + matchesList); else print("No match"); grab.sizes.addAll(matches); grab.change(); } }
Began life as a copy of #1006864
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: | #1006870 |
Snippet name: | New Algorithm [phase 1, dev.] |
Eternal ID of this version: | #1006870/1 |
Text MD5: | 9f58f744a1a0736b5d208b54fd844683 |
Author: | stefan |
Category: | javax / ocr / big data |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-11 07:02:03 |
Source code size: | 1708 bytes / 64 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 488 / 470 |
Referenced in: | [show references] |