/** * getCoords returns a list of coordinates of all the matches found for the element specified * @param targetImgPath is the image of the element that you want to find * @return list of coordinates of the matches found for the element specified */ public List<Point2D> getCoordsForAllMatchingElements(String targetImgPath) { Finder f = new Finder(takeScreenshot()); List<Point2D> coordsList = new ArrayList<>(); Match m; f.findAll(targetImgPath); while (f.hasNext()) { m = f.next(); coordsList.add(new Point2D.Double(m.getTarget().getX(), m.getTarget().getY())); } return coordsList; }
public Point2D getCoords(BufferedImage baseImg, String targetImgPath, double minSimilarityValue) { //set new minimum similarity Settings.MinSimilarity = minSimilarityValue; Match m; Finder f = new Finder(baseImg); Point2D coords = new Point2D.Double(-1, -1); f.find(targetImgPath); if (f.hasNext()) { m = f.next(); coords.setLocation(m.getTarget().getX(), m.getTarget().getY()); } //revert to default similarity Settings.MinSimilarity = DEFAULT_MIN_SIMILARITY; return coords; }
/** * getCoords returns the coordinates of the FIRST element that matches the specified * @param baseImg is the screenshot of the device * @param targetImgPath is the image of the element that you want to find * @return coordinates of the centre of the element found as Point2D */ public Point2D getCoords(BufferedImage baseImg, String targetImgPath) { Match m; Finder f = new Finder(baseImg); Point2D coords = new Point2D.Double(-1, -1); f.find(targetImgPath); if (f.hasNext()) { m = f.next(); coords.setLocation(m.getTarget().getX(), m.getTarget().getY()); } return coords; }
log(lvl, "doFind: Switching to TextSearch"); if (TextRecognizer.getInstance() != null) { f = new Finder(getScreen().capture(x, y, w, h), this); lastSearchTime = (new Date()).getTime(); f.findText(someText);
if (observedRegion.contains(r)) { lastSearchTime = (new Date()).getTime(); Finder f = new Finder(new Screen().capture(r), r); f.find(new Pattern(img).similar(Settings.CheckLastSeenSimilar)); if (f.hasNext()) { ((ImageFinder) finder).setIsMultiFinder(); } else { finder = new Finder(simg, observedRegion);
if (TextRecognizer.getInstance() != null) { log(lvl, "findInImage: Switching to TextSearch"); finder = new Finder(getScreen().capture(x, y, w, h), this); finder.findText((String) target);
f.findAllRepeat(); } else { f = new Finder(simg, this); Image img = null; if (ptn instanceof String) {
Image img = new Image(r.getScreen().capture(r).getImage()); Pattern p = new Pattern(img); Finder f = new Finder(img); boolean success = (null != f.find(p)); log(lvl, "testSetup: Finder setup with image %s", (!success ? "did not work" : "worked"));