svoid bwImageSearch_onFound(BWImage big, BWImage pat, float minSimilarity, IVF2 onFound) { int wp = pat.getWidth(), hp = pat.getHeight(); int w = big.getWidth(), h = big.getHeight(); float maxError = (1f-minSimilarity)*wp*hp; bigloop: 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) { maxError = diff; double sim = 1-diff/(wp*hp); Rect r = new Rect(x, y, wp, hp); onFound.get(r, sim); ping(); //if (diff == 0) break bigloop; } } }