/** * 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; }
if (f.hasNext()) { lastFindTime = (new Date()).getTime() - lastFindTime; m = f.next(); m.setTimes(lastFindTime, lastSearchTime); if (Settings.FindProfiling) {
finder.find(img); if (finder.hasNext()) { match = finder.next(); match.setTimes(0, now - lastSearchTime); if (match.getScore() >= getSimiliarity(ptn)) {
match = finder.next(); match.setImage(img); img.setLastSeen(match.getRect(), match.getScore());