!752 lib 1003153 // magic.jar import prophecy.common.image.ImageSurface; import prophecy.common.image.RGBImage; import prophecy.common.image.BWImage; sclass FoundImg { Rectangle r; S imageID; float sim; // similarity in 0 to 1 *() {} *(Rectangle *r, S *imageID, float *sim) {} } static new L found; static float correctness = 0.99f; p { BWImage big = shootScreenBW(); S patID = "#1004153"; // Search Button BWImage pat = loadBWImage(patID); long start = now(); int wp = pat.getWidth(), hp = pat.getHeight(); int w = big.getWidth(), h = big.getHeight(); float maxError = (1f-correctness)*wp*hp; for (int y = 0; y < h-hp; y++) for (int x = 0; x < w-wp; x++) { float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError); if (diff <= maxError) { float sim = 1-diff/(wp*hp); print("Found at " + x + "/" + y + " [sim: " + formatDouble(sim, 4) + "]"); Rectangle r = new Rectangle(x, y, wp, hp); found.add(new FoundImg(r, patID, sim)); quickShowZoomedImage(big.clip(r).toRGB()); //x += wp-1; } } done(start); }